title: How to prevent the cron job execution, if it is already running
body: <p>I have one php script, and I am executing this script via cron every 10 minutes on CentOS.</p>
  
  <p>The problem is that if the cron job will take more than 10 minutes, then another instance of the same cron job will start.</p>
  
  <p>I tried one trick, that is:</p>
  
  <ol>
  <li>Created one lock file with php code (same like pid files) when
  the cron job started.</li>
  <li>Removed the lock file with php code when the job finished.</li>
  <li>And when any new cron job started execution of script, I checked if lock
  file exists and if so, aborted the script.</li>
  </ol>
  
  <p>But there can be one problem that, when the lock file is not deleted or removed by script because of any reason.
  The cron will never start again.</p>
  
  <p>Is there any way I can stop the execution of a cron job again if it is already running, with Linux commands or similar to this?</p>