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.
- In a terminal run the command sudo nano /etc/crontab
- 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.
- 20 22 * * * root shutdown -h now
00 09 * * 1-5 root shutdown -h now - Select ctl+x and enter y to save.
Hi Jarrod,
Thank you very much for this useful tip.
Unfortunately it didn’t work for me.
Any other tips?
Thanks Ferit,
Did you restart your Pi after following the steps?