Skip to content

Instantly share code, notes, and snippets.

@fjallstrom
Last active December 25, 2015 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjallstrom/6955245 to your computer and use it in GitHub Desktop.
Save fjallstrom/6955245 to your computer and use it in GitHub Desktop.
<?php
$lockfile = '/tmp/cron_mylongrunningstuff.lock';
if(file_exists($lockfile)){
echo 'Hey, another process is already running, lockfile: '.$lockfile."\n";
exit(0);
}else{
if(touch($lockfile)){
# run script that takes sooper long time to complete
unlink($lockfile);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment