Last active
October 1, 2015 13:18
-
-
Save vijinho/b60d6fdae7d10d00d4a5 to your computer and use it in GitHub Desktop.
PHP script already running? FreeBSD/Linux compatible
This file contains hidden or 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 | |
function running() { | |
// check if already running, quit if so | |
exec("ps auxww | grep running.php | grep -v grep", $ps); | |
if (count($ps) > 1) { | |
echo "Already running!\n"; | |
return; | |
} | |
sleep(60); | |
} | |
running(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment