Quote:
Originally Posted by Raynon
Hi All,
I have set a cronjob to run a script at a frequency of 10 mins.
However, if the script takes more than 10 mins to complete, how will the cronjob behaves?
1) Does it ignore the current process and restart the whole process again?
2) Or does it stop to trigger the script again unless previous process has been completed?
|
Depends on your cron implementation but generally it will run another copy of the script 10 mins after the first one is started - regardless of how long the first run takes.
Solutions:
- Make your script reentrant - ie write it such that it running multiple times at once isn't a problem.
- Make your script aware of how many times it's currently running - ie create a lock file when it starts up and check for this every time you start.
- Don't use cron, have the script run continuously and manage it's own scheduling - ie sleep 600
- Don't use cron, get a better scheduler - depending on your enviornment, this could be something like anacron or control-m.