Schedule Shutdown on Linux

0
2867

Scheduling is one of the most interesting things you can do for increasing your productivity on lots of things. This technique is also quite useful in certain situations when you don’t want to manage things with your hands. For example, you can easily schedule SHUTDOWN on your system without many complexions. Yes, it’s possible to automate the shutdown of your system and also, wake up system!

Let’s take a look on automating the entire shutdown process.

Automatic shutdown

As the name suggests, every Linux system comes up with the “shutdown” tool. The tool is generally for shutting down the system with the power of performing a number of additional tasks.

For example, you can easily configure the tool for commencing shutdown at a specific time of the day.

sudo -s
OR
su -

shutdown -P now

This command tells the computer to shut it down just now. Alternatively, tell your computer to shut itself down at exactly 8:00 PM (20:00).

shutdown -P 20:00

Note that the time is in 24-hr format. That’s the problem with the “shutdown” tool. Don’t worry; you can easily use this awesome online converter for converting 12-hr into 24-hr.

If you want to cancel the scheduled shutdown, run this command:

shutdown -c

Rebooting with “shutdown”

As I said earlier, “shutdown” tool, despite its name, is capable of doing more than that. Run this command for rebooting your computer at 5:30 PM (17:30).

shutdown -r 17:30

If you wish to cancel, run the command as usual:

shutdown -c

Scheduling wakeups

There is another tool “rtcwake”. This tool suspends the system and then, wakes it up at a specific time. For acquiring the entire cheatsheet of “rtcwake”, run the following command:

rtcwake --help >> ~/rtcwake-help.txt

A popular method of suspending the system is suspending it to RAM. Suspending to RAM offers greater power saving and faster performance on waking up. Run the following command:

su -
OR
sudo -s

rtcwake -m mem -s 28800

Here, you will notice that we’ve used the time in seconds. It’s the best way to make precise calculations despite having a little usage difficulty. You can take the help of this tool for converting time to seconds.

If you want to suspend your system to disk, run this command:

rtcwake -m disk -s 43200

There are other things that you can do right from the same command. For example, if you want to start Firefox right after the computer wakes up, the command should look like this:

sudo rtcwake -m disk -s 43200 && firefox

Use the “&&” (without quotes) to tell Bash shell to perform “command1 AND command2 AND …”. This command line will start LibreOffice, GIMP, and Firefox one after another.

sudo rtcwake -m disk -s 43200 && libreoffice && gimp && firefox

Don’t suspend right away!

Generally, whenever you use the command with “rtcwake”, it will immediately suspend the system for waking up after the specified time period. However, you may not want to suspend when you run the command. In that case, use this command line:

rtcwake -m no -s 43200

It’ll tell “rtcwake” only to wake up the computer after 12 hours (43200 seconds). You have to manually suspend your system before the time so that the computer can do the job properly.

Enjoy!

LEAVE A REPLY

Please enter your comment!
Please enter your name here