Need to know how to shutdown your Linux system safely using command line or how to schedule shutdown at specific time? Here’s the answer!
shutdown command in Linux brings the system down in a secure way. This involves cutting the power to the main components of the system using a controlled process.
shutdown command allows you to shutdown the system immediately, or schedule a shutdown using 24 hour format. When the shutdown is initiated, all logged-in users and processes are notified that the system is going down by the signal
SIGTERM. In addition to, no further logins are allowed.
It’s important to mention that only root or user with
sudo privileges can execute shutdown command.
Below is the
shutdown command syntax in Linux:
shutdown [OPTIONS] [TIME] [MESSAGE]
- OPTIONS – Shutdown options such as halt, power-off or reboot the system.
- TIME – Specifies when to perform the shutdown process.
- MESSAGE – Specifies a message which will be broadcast to all users.
The basic usage is easy. All you have to do is to run the
As you can see from the image above, the command will not shutdown your Linux system immediately. If no time argument is specified,
+1 is implied, which means the shutdown process will be initiated in a minute from now, which is the default time interval.
How to Shutdown Linux System Immediately
To immediately shutdown the system, you can use
+0 or its alias
now after the
sudo shutdown now
How to Schedule Shutdown at Specific Time in Linux
You can also easily schedule Linux shutdowns to occur after a certain period of time or at a certain time.
The time argument can have two different formats. It can be an absolute time in the format
hh:mm or relative time in the format
m is the number of minutes from now.
For example, if you want to schedule a shutdown at 10 AM, then use the following:
sudo shutdown 10:00
It’s important to remember that the Linux shutdown command follows a 24 hours format. Therefore, to schedule the system to shut down at 10 PM:
sudo shutdown 22:00
Let’s now schedule a system shutdown in 30 minutes from now:
sudo shutdown +30
How to Broadcast a Custom Message
To show the message to the people who are logged in to your server before the server goes down, type your message after the time argument.
The following example, will shutdown the system in 20 minutes from now and notify the users that system upgrade will be performed:
sudo shutdown +20 "System upgrade in 20 minutes. Save your work."
The above command shall flash the message to all other logged in users and give them 20 minutes before the system goes for shutdown.
How to Restart Linux System Immediately Using the shutdown Command
To restart your Linux system in a safe way, use the following command below:
sudo shutdown -r now
-r option, which stands for reboot, requests that the system be rebooted after it has been brought down.
How to Schedule Restart at Specific Time Using the shutdown Command
Just like a shutdown, a restart can also be scheduled. For example, to schedule a restart for your system at 10 PM:
sudo shutdown -r 22:00
To schedule a system restart in 30 minutes from now:
sudo shutdown -r +30
Canceling the Shutdown
The scheduled shutdown can be canceled anytime using the
sudo shutdown -c
The command will immediately cancel the specified scheduled time of shutdown or restart. Keep in mind that this command cannot be used if you are immediately shutting down your system with the
How Do I Check My Scheduled Shutdown in Linux?
Now you are probably asking yourself: Is there any way to check if a shutdown countdown has been activated? Yes, this can be achieved by using the command below:
date -d @`cat /run/systemd/shutdown/scheduled | head -n 1 | cut -c6-15`
For example, if you set your Linux system to be shutting down at 10 PM (
sudo shutdown 22:00), the output of the above command will be:
I agree, it’s probably not the most elegant solution, but it does the job.
I hope this article helped you learn how to use the Linux
shutdown command and its options. It is also an effective and risk-free way to close all processes and power off the system.
Find out more about various options in
shutdown in its command line manual page.
If you have any questions or feedback, feel free to leave a comment.