Skip to content

Instantly share code, notes, and snippets.

@jrivero
Last active February 21, 2024 11:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrivero/741977 to your computer and use it in GitHub Desktop.
Save jrivero/741977 to your computer and use it in GitHub Desktop.
Control repeat of daemon
<?php
function control_daemon_repeat() {
$ps = "/bin/ps aux | /bin/grep -i ".$_SERVER["argv"][0]." | /bin/grep -v grep | wc -l";
$exec = exec($ps, $output, $return);
if ($output[0] > 1) die("*** Ya esta en ejecucion\n");
}
// Example
control_daemon_repeat();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment