Re: Checking for App running and restart if not
Re: Checking for App running and restart if not
- Subject: Re: Checking for App running and restart if not
- From: Christopher Nebel <email@hidden>
- Date: Thu, 22 Jan 2004 23:03:31 -0800
On Jan 22, 2004, at 8:46 PM, Michael Grant wrote:
On Jan 22, 2004, at 5:55 PM, Dan Doughtie wrote:
I've got a critical app running under 10.2.6 Server (on an Xserve)
that has
a nasty habit of crashing when I manage to get a day away from the
office.
Never habits when I'm at the office. I need some kind of timed
approach that
can check every 5 minutes to see if the app is running and if not then
relaunch. I think a cron approach is best and have it run an
Applescript.
I have cron call the following script once every five minutes via the
osascript command:
-- begin script
property appList : {{theApp:"iKey",
thePath:"/Users/mgrant/Applications/iKey.app/Contents/MacOS/iKey"},
{theApp:"Meteorologist",
thePath:"/Users/mgrant/Applications/M/Meteorologist/Meteorologist.app/
Contents/MacOS/Meteorologist"}}
repeat with anApp in appList
set cmd1 to "ps -x | grep " & (theApp of anApp) & " | wc -l"
set cmd2 to (thePath of anApp)
try
if (do shell script cmd1) as integer < 3 then do shell script
(thePath of anApp)
end try
end repeat
-- end script
I suspect this would actually be easier as a pure shell script (i.e.
without AppleScript), but I don't have much experience with those.
Alternatively, save this as a stay-open applet and leave the applet
running:
on idle
launch application "iKey" -- or whatever...
return 5 * 60 -- run again in 5 * 60 seconds, or five minutes.
end
If iKey is already running, the "launch" command does nothing. If it
isn't, it gets launched.
--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.