How to schedule turn off and on of a pi4 using cron ?

Hello, to save power I wanted to schedule precisely when my RPI has to be turned on and off.

I think Cron was a good solution so I try to edit contab and puting the follow lines for my pi4 to shutt off at 12:10 and turn at 12:12 for instance. but I think tvservice just shutt off hdmi ports. Do you now other commands ?

12 10 * * * tvservice -o #turn off
12 12 * * * tvservice -p; fbset -depth 8; fbset -depth 16 #turn on

But this code doesn't work.

After I saw things online about UUGear as a simple extension to the Raspberry to have clockwork management but I would like to avoid this solution.

Thank you in advance for your help, Antoine

  • Why do you think cron will be running when the Pi is switched off? – joan Jan 22 at 12:48
  • True ! maybe I should edit a config file ? – Antoine Riguillard Jan 22 at 12:48
  • Without external hardware, this is not possible. There is no way to restart the Pi once it has shut down. It also does not have a built-in realtime clock that could be used for this. It may support wake-on-LAN, but I haven't read anything about it. – PMF Jan 22 at 13:28
  • Additionally, the Pi does not have a power-save mode. So shutting it down (by software) does not really save power. – PMF Jan 22 at 13:29
  • @PMF Shutting down the operating system actually does leave the SoC in a sort of low power state -- it consumes considerably less than a running system would at idle anyway. Exactly how much I think varies by model and the Pi 4 is a bit special: raspberrypi.stackexchange.com/q/104944/5538 – goldilocks Jan 22 at 16:07

If it were me, I would get a cheap RPi zero W or just zero, or even the new rPi Pico and wire a micro USB to a PCB or breadboard with an NPN 2n2222 transistor and have it give power from the time a to time b and off otherwise. Then you have a handy little IOT switch and since you are not using mains power you can use just a transistor instead of a relay. But relays are cheap too.


In the context of saving power:

  1. the RPi cannot turn itself OFF - at least not completely

  2. the RPi cannot turn itself ON - this requires external intervention

  3. viewed as a ROI question, consider the cost of running RPi 24x7x365 is less than £5 per year

Using cron - and only cron, here's what you can do to save power:

  1. Scheduling a shutdown will help ensure your file system isn't corrupted:
12 10 * * *  /sbin/shutdown 
Note: `shutdown` requires root privileges, so run in the `root` crontab (`sudo crontab -e`)
  1. By itself, shutdown will not reduce power consumption very much at all, but having prepared the system for removing power, you may then "pull the plug".

This is all cron can do for you with respect to saving power. An automated system to turn RPi ON and OFF will require external components.


To underscore the "Return-on-Investment" point made earlier, this device could be part of a "power-saving" solution:

Outlet Timer

Plug your RPi power supply into this device, set its timer to switch power off at the desired time, and then just before that time invoke the shutdown in a crontab as shown above (to help prevent file system corruption).

But here's the best part: The cost of £7.49 will be amortized in less than 2 years.



There are actually extension boards that provide what you want (full power off, automatic restart using a real-time clock). An example is https://joy-it.net/de/products/rb-strompi3, however this one is quite expensive (in the order of $40) and probably only worth it if you need any of the other features it provides (such as a wide range power input, to drive the Pi from i.e. car batteries).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.