Skip to content

Instantly share code, notes, and snippets.

@bisko
Created February 23, 2017 16:55
Show Gist options
  • Save bisko/b0bd92e99042d99ba75b297e9b2fa553 to your computer and use it in GitHub Desktop.
Save bisko/b0bd92e99042d99ba75b297e9b2fa553 to your computer and use it in GitHub Desktop.
Monitors the `motion` process because it crashes at certain intervals
<?php
$ts = (int)file_get_contents('/tmp/wd_mt');
if (time() - 60 < $ts) {
exit();
}
do {
file_put_contents('/tmp/wd_mt', time());
$std = [];
$output = exec('ps ax | grep motion | grep -v grep', $std);
if (empty($std)) {
exec('/usr/sbin/service motion restart');
}
sleep(3);
} while (true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment