08 January 2012

shutdown Command in Linux/Unix

Leave a Comment
shutdown Command in Linux/Unix


                                   shutdown command in Linux/Unix use to shutdown down system in a safe way. To shutdown a system you need  root privileges.

Syntax


                shutdown  [option]  Time  [Message]

Time is mandatory.
* if value of Time is now or 0  , then system will immediately shutdown.
* value of Time can be m or +m, where m or +m is the number of minutes to wait until shutting down.
* value of Time can be  like  hh:mm which specifies the time on the 24hr clock.
*Message can be used to provide notification  to all user before shutdown the system .

Example
shutdown system after 23 minutes.
$ sudo shutdown 23

Broadcast message from sandeep@sandeep-desktop
(/dev/pts/0) at 22:36 ...

The system is going down for maintenance in 23 minutes!


shutdown system at 00:00 hrs.
$ sudo shutdown 00:00

Broadcast message from sandeep@sandeep-desktop
(/dev/pts/0) at 22:38 ...

The system is going down for maintenance in 82 minutes!


sending notification before shutdown the system
$ sudo shutdown +5 "system is going to shutdown in 5 minutes"
Broadcast message from sandeep@sandeep-desktop
(/dev/pts/0) at 22:41 ...

The system is going down for maintenance in 5 minutes!
system is going to shutdown in 5 minutes             //message

* if we write now or 0 instead of minute then system will immediately shutdown.
* To cancel shutdown press ctrl+c .


Different options of shutdown command


1. -h : shutdown and halt the system.

Example


                sudo shutdown -h now      //shutdown and halt the system immediately


                sudo shutdown -h +10 "system will going to halt in 10 minutes"



$ sudo shutdown -h +10 "system will going to halt in 10 minutes"

Broadcast message from sandeep@sandeep-desktop
(/dev/pts/0) at 22:53 ...

The system is going down for halt in 10 minutes!
system will going to halt in 10 minutes




2. -r : shutdown and reboot the system.

Example


                sudo shutdown -r now      //shutdown and reboot the system immediately


                sudo shutdown -r +10 "system will going to reboot  in 10 minutes"


$ sudo shutdown -r +10 "system will going to reboot in 10 minutes"

Broadcast message from sandeep@sandeep-desktop
(/dev/pts/0) at 22:55 ...

The system is going down for reboot in 10 minutes!
system will going to reboot in 10 minutes




3. -c : cancelling the shutdown process.

Example


                 sudo shutdown -c      
           

$ sudo shutdown -r +10 "system will going to halt in 10 minutes"

Broadcast message from sandeep@sandeep-desktop
(/dev/pts/0) at 22:55 ...

The system is going down for reboot in 10 minutes!
system will going to halt in 10 minutes
^Cshutdown: Shutdown cancelled                    //ctrl+c used if shutdown process running in foreground

 //shutdown process in background (& is use to run process in background)

$ sudo shutdown -r +10 "system will going to halt in 10 minutes" &
[1] 2177
$
Broadcast message from sandeep@sandeep-desktop
(/dev/pts/0) at 22:59 ...

The system is going down for reboot in 10 minutes!
system will going to halt in 10 minutes
^C                                                            //ctrl+c   doesnot   work

$ sudo shutdown -c
shutdown: Shutdown cancelled
[1]+ Done sudo shutdown -r +10 "system will going to halt in 10 minutes"
$



* TIME is not specified with this option, the first argument  is MESSAGE.


Other Options are


1.  -k   : Only send out the warning messages and disable logins, do not actually bring  the  system down.

$ sudo shutdown -k +10 "system will going to halt in 10 minutes"

Broadcast message from sandeep@sandeep-desktop
(/dev/pts/0) at 23:18 ...

The system is going down for maintenance in 10 minutes!
system will going to halt in 10 minutes
$


2. -H   :  Requests that the system be halted after it has been brought down.

3. -P    :  Requests that the system be powered off after it has been brought down.


4. -F    :  Force file system check.

$ shutdown -rF now


*Force the file system check on reboot

If You Liked This Post Please Take a Time To Share This Post

You May Also Like...

0 comments:

Post a Comment