Created
February 23, 2017 16:55
-
-
Save bisko/b0bd92e99042d99ba75b297e9b2fa553 to your computer and use it in GitHub Desktop.
Monitors the `motion` process because it crashes at certain intervals
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 | |
| $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