Reputation: 4660
If I have a cron job that run every 10 minutes and for some reason this one time it takes 12 minutes to run the job, will cron start another instance of my code while the previous one is still running? if so how can you prevent this on linux?
Upvotes: 9
Views: 1566
Reputation: 31
Yes. Cron will fire off a process at the scheduled interval, regardless if a previous one has not completed.
You can touch
a file, like stated in another answer, and check for its existence before engaging your process.
Or you could examine the process list to see if an "instance" is already running:
ps -ef | grep *your_script_name* | grep -v grep | wc -l
Upvotes: 3
Reputation: 8254
Yes, it will.
You should make your program create a .pid file (for example in /var/run/). When it starts, it should check if such file already exists and if so exit.
Which program/script are you running?
Upvotes: 10