While working on my Raspberry Pi Information Screen I wanted a way to automatically shut down the pi. As I have the pi on a timer to turn off and turn on, I wanted the pi to turn off gracefully 10 minutes before the timer cut the power. The easiest way I found was to just use a cron job.

  1. In a terminal run the command sudo nano /etc/crontab
  2. Now you have to decide when you want your Pi to turn off. The best thing I have found is the crontab.guru website. It allows you to test and get the syntax correct. It also adds a text representation of when the job will run. I will add 2 commands as I want my Pi to turn off at 10:20Pm every day and at 9:00AM every weekday respectively. 
  3. 20 22 * * * root shutdown -h now
    00 09 * * 1-5 root shutdown -h now
  4. Select ctl+x and enter y to save.