Syntax
shutdown (options) (parameters)
Options
-c: When executing the "shutdown -h 11:50" command, you can interrupt the shutdown command by pressing the + key;
-f: Do not execute fsck during reboot;
-F: Execute fsck during reboot;
-h: Shut down the system;
-k: Just send a message to all users, but will not actually shut down;
-n: Shut down without calling the init program, handled by shutdown itself;
-r: Restart after shutdown;
-t<seconds>: Delay between sending warning messages and deleting messages.
Parameters
-
[time]: Set how long after the shutdown command is executed;
-
[warning message]: The message to be sent to all logged-in users.
Examples
Specify immediate shutdown:
shutdown -h now
Specify shutdown in 5 minutes, while sending a warning message to logged-in users:
shutdown +5 "System will shutdown after 5 minutes"
Explanation:
1: Immediately shut down the Linux system, where now is equivalent to a time of 0
[root@db-server ~]# shutdown -h now
Broadcast message from root (pts/1) (Sat Jan 10 18:51:34 2015):
The system is going down for system halt NOW!
2: The system will restart in 2 minutes, where +m indicates minutes before shutdown or startup.
[root@db-server ~]# shutdown -r +2
Broadcast message from root (pts/2) (Sat Jan 10 19:56:00 2015):
The system is going DOWN for reboot in 2 minutes!
3: Set the system to shut down at that specific time
[root@db-server ~]# shutdown -h 12:30
or
[root@db-server ~]# shutdown -h 12:30 &
[1] 4578
It is best to use the command & to run the shutdown command in the background. This does not affect other current operations.
Set how long after to execute the shutdown command. The time parameter can be in hh:mm or +m format. The hh:mm format indicates when to execute the shutdown command. For example, “shutdown 10:45” means to execute the shutdown command at 10:45. +m indicates the shutdown will occur m minutes later. A special use is to use now to indicate immediate execution of shutdown. It is worth noting that this parameter cannot be omitted. Additionally, if it is currently 22:30 and you execute shutdown -h 22:00 &, then it will shut down the next day.
4: Cancel the previous shutdown command
As shown below, executing the command to let Linux shut down at 12:30 can be canceled using CTRL+C if the time is not suitable.
[root@db-server ~]# shutdown -h 12:30
Shutdown cancelled.
[root@db-server ~]#
Alternatively, you can execute the following command in another command window
[root@db-server ~]# shutdown -c
5: Send a message to all logged-in users
[root@db-server ~]# shutdown -k "now"
Broadcast message from root (pts/2) (Sat Jan 10 20:09:14 2015):
The system is going down to maintenance mode NOW!
Shutdown cancelled.
Other logged-in session windows will receive the following message
[root@db-server ~]#
[root@db-server ~]#
Broadcast message from root (pts/2) (Sat Jan 10 20:11:34 2015):
The system is going down to maintenance mode NOW!
Generally use the following syntax as shown below
[root@db-server ~]# shutdown -k now "The Server will shutdown now"
Broadcast message from root (pts/1) (Sat Jan 10 20:14:54 2015):
The Server will shutdown now
The system is going down to maintenance mode NOW!
Shutdown cancelled.
6: Restart without performing disk checks
[root@db-server ~]# shutdown -fr now
Broadcast message from root (pts/1) (Sat Jan 10 20:23:59 2015):
The system is going down for reboot NOW!
7: Shut down the system after a certain number of seconds and send a prompt message to users
[root@db-server ~]# shutdown -t 10 -h now "System will shutdown 10 seconds later"
Broadcast message from root (pts/1) (Sat Jan 10 20:33:36 2015):
System will shutdown 10 seconds later
The system is going down for system halt NOW!
Note: All content in this article is sourced from the internet

