I have a job that I would like to "daemonize" on Unix: I want it to come up when the computer boots, and I want it to restart if it goes down.
A simple way to do this is to setup a cronjob that runs every 10 or 20 minutes. The cronjob should restart the application if it's not already running.
How do I write this last part of the script: "If the job is not currently running, then start the job"?
Answer
This approach is fast and cheap and not bulletproof:
#!/usr/bin/perl -w
$l = `ps x`;
if (not $l =~ /mzscheme/) {
system('~/utils/src/plt/bin/mzscheme &');
}
I put that script in a cron file.
No comments:
Post a Comment