Switching Off

Team-Fly    

Solaris™ Operating Environment Boot Camp
By David Rhodes, Dominic Butler
Table of Contents
Chapter 2.  Booting and Halting the System


A Solaris system is normally shut down using the shutdown command. This can only be run by the root user, and it is recommended that it be run from the root directory. On older versions of Solaris, the command actually checked that you were in the root directory, but more recent versions don't botherthey simply change you to that directory. However, if you always run it from the root directory, you won't have problems unmounting a filesystem that you happened to be in when you ran the command.

You may find that the shutdown command is not in your PATH, since some companies prefer not to be in a position where it can be called accidentally. If this is the case it needs to be called using its full path name (either /etc/shutdown or /usr/sbin/shutdown; the two are linked). If run with no options, shutdown will ask if you are sure that you really want to do this before continuing. If you answer in the affirmative, a message will be broadcast (using the wall command) to warn all users that the system will be shut down in 60 seconds. The script will then wait 60 seconds before issuing a further warning and proceeding with the actual shutdown. If you want to shut down immediately, the following is the usual way to achieve this:

 hydrogen# hydrogen# /etc/shutdown -y -g0 -i0 Shutdown started. Mon Apr  8 15:34:40 CEST 2002 Changing to init state 0 - please wait Broadcast Message from root (pts/5) on hydrogen Mon Apr  8 15:34:41... THE SYSTEM hydrogen IS BEING SHUT DOWN NOW ! ! ! Log off now or risk your files being damaged hydrogen# 

The "-y" flag causes the shutdown program to not bother asking if you are sure you wish to do this. The "-g0" sets the grace period to 0 (so the users don't get any time to finish what they are doing). If the "-g" flag is not used the default grace period is 60 seconds. The "-i0" flag specifies that the run level should change to 0 (so if you used "-i6" instead, the system would reboot).

In the above example, the command was run from a terminal session other than the system console so we see the output shown and return to our shell prompt. Meanwhile, the shutdown continues with output directed to the system console.

An alternative version of the shutdown command is available for people more used to administering a Berkeley Software Distribution (BSD) UNIX system. This is located in the /usr/ucb directory and is simply used by running the command with a single parameter saying when you wish the shutdown to take place. For example, to shut the system down immediately we would run the command as follows:

 hydrogen# /usr/ucb/shutdown now Shutdown at 13:18 (in 0 minutes) [pid 450] hydrogen#  *** FINAL System shutdown message from root@hydrogen *** System going down IMMEDIATELY System shutdown time has arrived 

Both of the above examples will end by calling init, which will handle the remainder of the shutdown process by calling the appropriate scripts under the rc directories using the parameter "stop."

Occasionally, there may be a situation where you do not want to perform a normal shutdown of the server. You may want to just get it down in the quickest possible time. There are a number of ways of doing this; the simplest is probably by using either the halt or poweroff command. Both of these will simply perform a sync (to save any data that was in the process of being written to disk) and then shut down the system. The only differ ence between the two commands is that poweroff will also attempt to power the server off, which will only work if the hardware supports it. Both of them support a "-n" option, which will prevent them from even doing the sync before shutting down.


    Team-Fly    
    Top
     



    Solaris Operating Environment Boot Camp
    Solaris Operating Environment Boot Camp
    ISBN: 0130342874
    EAN: 2147483647
    Year: 2002
    Pages: 301

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net