2
3
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"?
Only by using a program that is guaranteed to be running all the time (such as init or upstart) can you be sure that your program will (almost) always be alive. But I see from some of your comments below, you don't have root access. Just be aware that any periodic checking solution (pid file / cron) is only as good as the checking interval. – DaveParillo – 2009-11-04T04:48:16.940