Turn the monitor on and off automatically
To turn the monitor on/off on a daily schedule, grab this script and put it in /home/pi/rpi-hdmi.sh. Next, make it executable:
chmod +x /home/pi/rpi-hdmi.sh
Now we’ll need to add a cron entry to call this script at the desired time, so open the cron editor:
And add the following lines at the bottom of the file:
Turn HDMI Off (22:00/10:00pm)
0 22 * * * /home/pi/rpi-hdmi.sh off
Turn HDMI On (7:00/7:00am)
0 7 * * * /home/pi/rpi-hdmi.sh on
The first number (0) is the minutes and the second number on each of those lines (22 and 7) is the hour in 24 hour time. So in this example, the monitor would turn off at 10:00pm and back on again at 7:00am. Adjust the time for your needs.
Keep in mind: this does not turn the Raspberry Pi off! It just turns off the monitor, saving energy and hopefully extending the life of your monitor. The Raspberry Pi is still on and running however.