Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 
Last thing I wanted to do was to set a automatic reboot for the Raspberry Pi to keep things refreshed and also to trigger my relay once a week to reset the device I had connected. The relay was just to cycle the power to the third party device, so could be set for any time/date really, I just chose to do it weekly. Adjust times to suit yourself.

There is a lot of info on how to set up cron, this is the method I chose.

Open a terminal and type:

sudo nano /etc/cron.d/reboot

Copy and paste this into this file and then press CTRL O followed by ENTER to save and CTRL X to exit. There is no need to reboot after setting up cron - it will pick it up automatically.

# m h dom mon dow user command

#Reboot Raspberry Pi
15 0 * * 0 root /sbin/shutdown -r now

#Activate relay on GPIO18
30 0 * * 0 root python /home/pi/relay.py

The # element at the top shows the format for time. Minute, Hour, Day of Month, Month, Day of week, User & Command. so this example shows a reboot at 00:15 on a Sunday (days are 0-6, Sunday to Monday). The relay is set to trigger at 00:30 on a Sunday to allow time for the Pi to reboot (can take anything from 30 seconds to a couple of minutes from experience).