The shutdown command bring the Linux based system or server down. Only the superuser (root user) can shut the system down. Open a command-line terminal (select Applications > Accessories > Terminal), or login to remote server using the ssh command, and then type the following command to shutdown the Linux server immediately:
# shutdown -h now
# shutdown -h +5
Broadcast message from vivek@vivek-laptop (/dev/pts/0) at 16:57 ... The system is going down for halt in 5 minutes!
-h (halt) option
The -h option requests that the system be either halted or powered off after it has been brought down, with the choice as to which left up to the system:
# shutdown -h 6:30
# shutdown -h 20:00
The above will turn the server off at 8:00 PM.
The -H option requests that the system be halted after it has been brought down:
# shutdown -H +10
-P (power off) option
The -P option requests that the system be powered off after it has been brought down:
# shutdown -P +10
Broadcast message from vivek@vivek-laptop (/dev/pts/1) at 17:00 ... The system is going down for power off in 10 minutes!
You can also type the poweroff command instead of typing shutdown -P:
How do I Cancel The System Shutdown?
You can press [CTRL+C] or type the following command to cancel a running shutdown:
# shutdown -c
Sample output (the command was issued on tty01):
shutdown -h +10 Broadcast message from vivek@vivek-laptop (/dev/pts/1) at 17:04 ... The system is going down for halt in 10 minutes! shutdown: Shutdown cancelled
How Do I Display Custom Shutdown Message?
Use the following syntax:
# shudown -h TIME "YOUR-MESSAGE-HERE"
In this example, shutdown the server for hard disk replacement:
# shutdown -h +5 "The server is going down for 'harddisk replacement'"
Broadcast message from vivek@vivek-laptop (/dev/pts/0) at 17:11 ... The system is going down for halt in 5 minutes! The server is going down for 'harddisk replacement'
Linux Server Shutdown and Log Files
The following two files are updates when the system goes down for the poweroff / halt or reboot operations:
- /var/run/utmp – Where the current runlevel will be read from; this file will also be updated with the runlevel record being replaced by a shutdown time record.
- /var/log/wtmp – A new runlevel record for the shutdown time will be appended to this file.
How Do I Display the System Shutdown Time?
Use the last command as follows:
# last -x shutdown
shutdown system down 2.6.18-238.el5 Sat Jan 22 06:40 - 05:51 (10+23:10) shutdown system down 2.6.18-194.32.1. Sun Jan 16 13:26 - 06:40 (5+17:14) shutdown system down 2.6.18-194.26.1. Sat Jan 8 04:17 - 13:25 (8+09:08) shutdown system down 2.6.18-194.26.1. Mon Nov 15 16:46 - 04:16 (53+11:30) shutdown system down 2.6.18-194.17.1. Wed Oct 27 01:00 - 02:00 (18+02:00) shutdown system down 2.6.18-194.8.1.e Thu Aug 12 00:18 - 09:02 (20+08:43) shutdown system down 2.6.18-194.8.1.e Wed Jul 14 14:07 - 16:19 (5+02:12) shutdown system down 2.6.18-194.8.1.e Tue Jul 13 20:21 - 14:06 (17:45) shutdown system down 2.6.18-194.8.1.e Tue Jul 13 12:13 - 20:20 (08:07) shutdown system down 2.6.18-194.8.1.e Tue Jul 13 11:48 - 12:13 (00:24) shutdown system down 2.6.18-194.8.1.e Tue Jul 13 10:38 - 11:48 (01:09) shutdown system down 2.6.18-194.el5 Tue Jul 13 10:32 - 10:38 (00:05) wtmp begins Tue Jul 13 10:26:19 2010
- Man pages: shutdown(8)
|Category||List of Unix and Linux commands|
|Network Utilities||dig • host • ip • nmap|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|