July 25th, 2003, 01:10 AM
timeout for cron job - pls help!
i have two cron jobs, one running after another ends. If the first cron job keeps executing, and gets hang, i will like to have a timeout for the cron job, so that the next cron job can run. How can I do it?
August 6th, 2003, 11:15 AM
why not just separate them by several hours? Set the first one at 2am and the second at 5am. Or swap them around? Or do they both hang? What OS are you using and what shell?
August 6th, 2003, 12:36 PM
something similar to this could work (untested):
It *could* kill the wrong process though.
echo "kill $?" | at now+1h
If the program has quit by itself till then, the PID that comes from $? will not be valid anymore. But itīs unlikely that your PIDs wrap over within an hour.
You could also use a "lock file" for the first process and have the second process check if #1 is still running and if so, kill it.