2018-05-22
Watchdog for the Raspberry Pi Camera
My second Raspberry Pi is now running since more than 63 days without a break, also known as 24/7. It takes a photo at the window every minute, except when it has to do some other jobs, or goes down unexpectedly. But thanks to the built-in hardware "watchdog", the Pi Zero W goes up again automatically. On two occasions, raspistill and the "Camera Module v2" stopped working for no reason, but everything else was still just fine. This is why i created my own software watchdog exclusively for checking the function of the attached camera:
I wrote a Unix shell script looking for the latest photo every thirty minutes. And if the JPEG file is older than 240 seconds, the Pi Zero W will reboot to start fresh. I have scheduled this task in the crontab of the root user, as required by "shutdown -r now". Because of this, i did not need to touch the Raspberry Pi physically since at least one month. But i keep an eye on it through logs created by involved processes as part of my monitoring system. This way i identify and resolve issues when they occur without downtime.