Time-controlled shutdowns or reboots are needed many times. For example you want to go to sleep. However, Steam is still updating your installed games. You want to have your Steam games ready updated when you’re waking up again. You look into your Steam download queue and you find out that it just needs two more hours. With a time-controlled shutdown you can go to sleep without interrupting this update process. This short article describes how to shutdown or restart your Linux or Windows machine by a given time.

Advertisements

Time-controlled shutdown/reboot on Linux

Shutdown

The good thing here is that every Linux distribution can execute this commands. They are the same on every distribution and every system. So, with the following command you tell your Linux distribution to shutdown your computer after 2 hours automatically:

user@machine:~$ sudo shutdown -h 120

The command shutdown speaks for itself. With the parameter -h you tell the shutdown command to power off the computer. The alternative would be halt. Still today some PCs aren’t turning off the power when they receive a halt. With the poweroff signal however, the PC is totally powering off. The number, after the -h switch, is the time in minutes when the PC should power off from now on. In this example this would be 120 minutes. You could also directly enter a time here. In the following example the PC would power off at 21:45:

user@machine:~$ sudo shutdown -h 21:45

And if you want to shutdown your machine right now, you can use the word NOW:

user@machine:~$ sudo shutdown -h NOW
Reboot

With the same shutdown command you can also do a reboot. To do so, simply replace the -h switch with -r. The following example reboots the computer after 120 minutes (two hours):

user@machine:~$ sudo shutdown -r 120

You can also enter a time here as well:

user@machine:~$ sudo shutdown -r 21:45

And as you may have seen the pattern, the following command restarts the PC right now:

user@machine:~$ sudo shutdown -r NOW
Cancel an active shutdown or reboot

If you entered a time-controlled shutdown or reboot and you want to cancel it for whatever reason, simply use the shutdown command with the -c switch like this:

user@machine:~$ sudo shutdown -c

Time-controlled shutdown/reboot on Windows

In order to do a time-controlled shutdown or reboot on Windows, we need a terminal window. This can be easily opened with pressing the keyboard combination Windows+R. In the following window enter cmd and click OK:

Time-controlled shutdown start cmd

The run window

 

Afterwards you will see a console terminal which looks like this:

Time-controlled shutdown cmd started

A command line in Windows 7

Shutdown

For a time-controlled shutdown under Windows, there is (just like in Linux) the tool shutdown available. The following command would shutdown your Windows PC in 2 hours:

C:\Users\testuser> shutdown /s /t 1200

Like in Linux, the /s switch tells your PC to shutdown / power off. The /t switch tells the shutdown command in how many seconds the PC should shutdown. If you want to shutdown your PC “immediately”, simply omit the /t switch like this:

C:\Users\testuser> shutdown /s

The PC will then shutdown within the next 60 seconds (which is the default value when executing the shutdown command without a timer under Windows).

Restart

For restarting, replace the /s switch with the /r switch. For e.g., this will trigger a reboot after two hours:

C:\Users\testuser> shutdown /r /t 1200

Or to trigger a reboot right now (60 seconds):

C:\Users\testuser> shutdown /r
Cancel an active shutdown or reboot

If you entered the wrong time for the shutdown / reboot or if you simply changed your mind, enter the following command to cancel the active shutdown / reboot:

C:\Users\myuser> shutdown /a

Conclusion

For a lot of people, shutting down or rebooting the PC at a specific time is a very needed feature. I’m the best example for this kind of person. Since I’ve moved to my new living place, the internet is only a twentieth of were it was before. This means that downloading games through Steam are time and bandwidth consuming. But starting the download right before I go to bed and use the shutdown command to plan a shutdown helps a little bit. Over night my bandwidth can be fully used by the Steam so that nobody gets distracted. When the download is finished, my system is shutting down which saves energy and protects the hardware. So knowing how to shutdown your PC at a specific time is a “must know”. And now you know as well 🙂

Do you have any thoughts about this topic you want to share? Are you actively using time-controlled shutdown or reboots? Let me know in the comments below.

Further links

Advertisements