Being able to automatically shut down your computer can be quite handy. It allows you to perform tasks automatically or save energy by scheduling the shutdown for a later time. In this article, we will learn how to schedule shutdown on the Ubuntu Linux operating system using the terminal.
Shutdown or Restart Ubuntu Using Linux Command Line
On Ubuntu Linux, you can use the shutdown
command to schedule a system shutdown or restart. This command allows you to perform various tasks, including setting a shutdown timer. The syntax for the “shutdown” command is as follows:
shutdown [option] [time] [message]
Where:
option
: An option of a command, such as-h
to shutdown,-r
to restart,-c
to cancel the timer job.time
: Timer duration, which can be a specific time (eg )21:30
or after a certain amount of time (eg+60
for after 60 minutes).message
: The message displayed before the shutdown timer.
Note: You need administrative privileges (sudo) to run the ‘shutdown’ command, as only users with administrative rights can perform shutdown tasks.
Examples of Using the Shutdown Command
Here are some examples of how to use the shutdown command to schedule a shutdown on Ubuntu 22.04:
Shutdown after 30 minutes:
sudo shutdown -h +30 "Timer to shutdown after 30 minutes"
This command will initiate a system shutdown in 30 minutes, displaying the message “Timer to shutdown after 30 minutes“.
Shutdown at a specific time:
sudo shutdown -h 21:30 "Time to shutdown at 21:30"
This command will schedule a system shutdown for 9:30 PM (21:30 in 24-hour format), displaying the message “Time to shutdown at 21:30”.
Cancel a scheduled shutdown:
sudo shutdown -c
If you’ve scheduled a shutdown and want to cancel it, you can use the ‘-c’ option to cancel the pending shutdown timer job.
By utilizing the ‘shutdown’ command, you can easily schedule system shutdowns or restarts on your Ubuntu Linux machine, streamlining your workflow and ensuring efficient energy management.
For more advanced usage or troubleshooting, refer to the official “shutdown” command documentation by typing man shutdown
in the terminal.