How to automatically turn off and on your monitor from your Raspberry Pi
Viktor Petersson
21

Thanks for the article.

I am trying to write a cron schedule to turn my HDMI port for my Raspberry Pi on and off at different times during the day, depending on if its a weekend or week day.

To turn off the HDMI port I call: /home/pi/rpi-hdmi.sh off
To turn on the HDMI port I call: /home/pi/rpi-hdmi.sh off

I know how to setup the weekday AND weekend requests separate from one another.

My requirements: 
M-F: (turn it off all day, only back on when we get home after work)
Every day during the week I want the HDMI port on at 7AM, and off at 9AM. I want it back on when we get home at work from 5:00 PM and to turn off for the day at 11PM.

Sat-Sun: (leave it on all day)
On at 7AM, Off at 11PM.

So since I have a global on and off time of 7AM and 11PM every day we could say:
00 7 * * * * /home/pi/rpi-hdmi.sh on
00 23 * * * * /home/pi/rpi-hdmi.sh off

Then for the weekdays:
00 9 * * 1–5 /home/pi/rpi-hdmi.sh off (off at 9AM)
00 17 * * 1–5 /home/pi/rpi-hdmi.sh on (on at 5PM)

My question to you is one of order — how do I know if these will be executed in this order? Is there a better way to write this?

Thanks!

Show your support

Clapping shows how much you appreciated Lee McArthur’s story.