Submitted by abitowhit on Thu, 12/26/2019 - 02:11
In order to insure that overwatch.py is running (the python script which performs face recognition) I have created a bash script which will fire every hour at 15 min past.
This is accomplished by using the following bash script called chk.sh (Borrowed from quickcpm)
(Change the directory structure to the one you are using for the overwatch scripts)
Be sure to chmod so it is executable.
** Note that it is only checking for python running. If you have multiple python scripts running you will need to alter it.
/home/pi/overwatch/chk.sh
#!/bin/bash
ps cax | grep python > /dev/null
if [ $? -eq 0 ]; then
echo "overwatch is running."
else
echo "Starting overwatch."
x-terminal-emulator -e sudo /home/pi/overwatch/overwatch.sh
fi
exit
crontab -e
15 * * * * /home/pi/overwatch/chk.sh >/dev/null 2>&1 # overwatch monitor
At 15 minutes past every hour, the script will check to see if python is processing and if not, restart it.
If you need to kill the process.
type in ps cax | grep python to get the PID and type sudo kill -9 1234 where 1234 is the process ID number.
If you are running chk.sh then you will need to remark it out in crontab so it does not restart it.