Last active
December 25, 2015 09:39
-
-
Save fjallstrom/6955245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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