Linux – Don’t run cron job if already running

cronlinuxPHP

I know this question has been asked already but I either didn't understand the answer or it didn't apply to me.

I have a php script that I am calling every 1 minute using CPanel to set up the Cron Job. The nature of the script means that it could overrun for just over the minute so I need to know how to stop the next one running if the first one hasn't completed.

I have a VPS running CENTOS 5.5 and have access to WHM and CPanel. I have never used Linux before (only just got the server yesterday) so I have no idea what I am doing and would appreciate some help if possible. If I need to provide more information please let me know (I don't know what info you would need at the moment).

Thanks.

Best Answer

Please see Process Management. You will probably want to use a lock file. You can use flock for example.

Why can't you let your jobs complete?

Your questions says "I either didn't understand the answer or it didn't apply to me", but you don't say in what way. Please be more specific.

Related Topic