How to prevent the cron job execution, if it is already running

MISHLIMITED

New Member
I have one php script, and I am executing this script via cron every 10 minutes on CentOS.The problem is that if cron will take more than 10 minutes, than another same cron will start.I tried one trick, that is:[*]Created one lock file with php code ( same like pid files ) whencron started.[*]Removed the lock file with php code when cron finished.[*]And any new cron started execution of script, I checked that if lockfile is exists than abort the script.But there can be one problem that, when the lock file not deleted or removed by script because of any xyz reason.The cron will never start again.Is there any way I can stop the execution of cron again if it is already running with linux commands or similar to this ?So please provide me any suggestions regarding this issue.Thanks in advance.
 
Back
Top