Electricity is expensive at the moment and as such every little bit that you save helps control this cost just that little bit more. However, I am guilty of often just leaving devices on for no apparent reason, and so this next little trick goes a long way in making sure I can’t get away with leaving my study a blur of various color LED lights all night long.
As with Window’s scheduled task functionality, Ubuntu comes with its Crontab, a service that is able to run scheduled cron jobs that you can assign per user. We’ll leverage this ability to make sure that our PC powers down just after midnight, just in case we forgot to hit the power button before turning in for the night.
Because the native shutdown command required elevated sudo rights, open the your crontab with the following command via the terminal:
sudo crontab -e
Note that if you don’t have a crontab set up yet, it will prompt you to select an editor. And yes, they are right. Nano is the simplest editor to use in this instance.
On a new line, enter:
01 00 * * * /sbin/shutdown -P now
Save and exit. The machine will automatically install the updated cron.
What the above command does is say that at 1 minute past midnight, execute the shutdown command (which is stored in /sbin) using the -P flag to indicate power down and now to say this must happen straight away.
Nifty.