I have a python3 script that uses OpenCV and a Raspberry Pi cam. It runs almost 24/7. Using crontab the pi will reboot every night at midnight and the script will begin running again. This is mostly so that if something goes wrong (like if one of the python scripts unexpectedly stops and fails to restart somehow) everything has a chance to be reset, and because I'm afraid running the camera 24/7 is somehow bad for it.
To prevent potential problems I was planning to killall python
before the reboot, and possibly release the camera as well. The problem is, I don't know if it is even necessary to kill python, release the camera, or reboot. I'm just assuming it's a good idea. If releasing the camera is necessary then I don't know how I'd do that either.
Can someone help me out here?
This is what I picture the crontab would look like (I haven't tested it yet and I'm new to this, so I apologize if my syntax is wrong):
@reboot sudo modprobe bcm2835-v4l2
@reboot python3 /home/pi/motion/motionDetection.py
@reboot python3 /home/pi/motion/CPUtracker.py
*/5 * * * * pgrep -f /home/pi/motion/motionDetection.py || nohup python3 /home/pi/motion/motionDetection.py
*/5 * * * * pgrep -f /home/pi/motion/CPUtracker.py || nohup python3 /home/pi/motion/CPUtracker.py
59 23 * * * killall python
###59 23 * * * [code to release camera]
0 0 * * * sudo reboot