Skip to content

Instantly share code, notes, and snippets.

@vijinho
Last active October 1, 2015 13:18
Show Gist options
  • Save vijinho/b60d6fdae7d10d00d4a5 to your computer and use it in GitHub Desktop.
Save vijinho/b60d6fdae7d10d00d4a5 to your computer and use it in GitHub Desktop.
PHP script already running? FreeBSD/Linux compatible
<?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