System Administration Guide, Volume 1

When to Shut Down the System

Solaris software is designed to be left running continuously so that the electronic mail and network software can work correctly. However, some system administration tasks and emergency situations require that the system is shut down to a level where it is safe to remove power or brought to an intermediate level, where not all system services are available, such as:

See Chapter 7, Shutting Down and Booting a System (Overview) for a complete list of system administration tasks requiring a system shutdown.

For information on using your system's power management features, see Using Power Management.

How to Shut Down a System

Using the init and shutdown commands are the primary ways to shut down a system. Both commands perform a clean shutdown of the system, which means all file system changes are written to the disk, and all system services, processes, and the operating system are terminated normally.

Using a system's stop key sequence or turning a system off and then on are not clean shutdowns because system services are terminated abruptly. However, is it sometimes necessary to use these actions in emergency situations. See Chapter 10, SPARC: Booting a System (Tasks) or Chapter 11, IA: Booting a System (Tasks) for instructions on system recovery techniques.

The following table describes the various shutdown commands and provides recommendations for using them.

Table 9-1 Shutdown Commands

Command 

Description 

This Command Is ... 

shutdown

An executable shell script that calls the init program to shut down the system. The system is brought to run level S by default.

Recommended for servers running at run level 3 because users are notified of the impending shut down as are the systems that are mounting resources from the server being shut down.  

init

An executable that kills all active process and syncs the disks before changing run levels.

Recommended for standalone systems when other users will not be affected. It provides a faster system shutdown because users are not notified of the impending shutdown. 

reboot

An executable that syncs the disks and passes booting instructions to the uadmin system call, which, in turn, stops the processor.

Not recommended; use the init command instead.

halt

An executable that syncs the disks and stops the processor.

Not recommended because it doesn't execute the /etc/rc0 script, which stops all processes, syncs the disks, and unmounts any remaining file systems.


Note -

The /usr/sbin/shutdown command, not the /usr/ucb/shutdown command, is used in this chapter and throughout this book.


When to Turn Off Power to Devices

Turning off power to all system devices is necessary when you need to:

System devices to power down include the CPU, the monitor, and external devices such as disks, tapes, and printers.

The steps for turning off power to all devices are performed in addition to shutting down the system.

Notifying Users of System Down Time

When the shutdown command is initiated, a warning followed by a final shutdown message is broadcast to all users currently logged onto the system and all systems that are mounting resources from the affected system.

This is why the shutdown command is recommended over the init command when used on a server. When using either command, you might want to give users more notice by sending a mail message about any scheduled system shutdown.

Use the who(1) command to determine which users on the system need to be notified. This command is also useful for determining a system's current run level, which is described on "How to Determine a System's Run Level".

How to Determine Who Is Logged in to a System

  1. Log into the system to be shut down.

  2. Display logged-in users with the who command.


    $ who
    

Example--Determining Who Is Logged in to a System

The following example displays the output of the who command.


$ who
holly 1     console      May  7 07:30 
kryten      pts/0  2     May  7 07:35	 (starbug) 4
lister      pts/1        May  7 07:40 3 (bluemidget)
  1. Identifies the user name of the logged-in user.

  2. Identifies the terminal line of the logged-in user.

  3. Identifies the date and time the user logged in.

  4. (Optional) Identifies the host name if a user is logged in from a remote system.

How to Shut Down a Server

  1. Become superuser.

  2. Find out if users are logged into the system.


    # who
    

    A list of all logged-in users is displayed. You might want to send mail or broadcast a message to let users know that the system is being shut down.

  3. Shut down the system by using the shutdown(1M) command.


    # shutdown -iinit-state -ggrace-period -y 
    

    -iinit-state

    Brings the system to an init state different from the default of S. The choices are 0, 1, 2, 5, and 6. 

    -ggrace-period

    Indicates a time (in seconds) before the system is shut down. The default is 60 seconds. 

    -y

    Continues to shut down the system without intervention; otherwise, you are prompted to continue the shutdown process after 60 seconds. 

  4. If you are asked for confirmation, type y.


    Do you want to continue? (y or n): y
    

    If you used the shutdown -y command, you will not be prompted to continue.

  5. Type the superuser password, if prompted.


    Type Ctrl-d to proceed with normal startup,
    (or give root password for system maintenance): xxx
    
  6. After you have finished the system administration tasks, press Control-d to return to the default run system level.

  7. Use the following table to verify the system is at the run level specified in the shutdown command.

    If the System Was Brought To ... 

    The SPARC Based System Prompt Should Be ... 

    The IA Based System Prompt Should Be ... 

    Run level S (single-user state) 

    Run level 0 (power-down state) 

    ok or >

    type any key to continue

    Run level 3 (multiuser state with remote resources shared) 

    hostname console login:

    hostname console login:

SPARC: Example--Bringing a System to Run Level S (Server)

In the following example, the shutdown is used to bring a SPARC based system to run level S (single-user state) in 3 minutes.


# who
root       console      Jul 14 13:53
# shutdown -g180 -y
 
Shutdown started.    Wed Jul 14 13:55:55 MDT 1999

Broadcast Message from root (console) on earth Wed Jul 14 13:55:56...
The system earth will be shut down in 3 minutes 
.
.
.
Broadcast Message from root (console) on earth Wed Jul 14 13:58:28...
The system earth will be shut down in 30 seconds
.
.
.
INIT: New run level: S
The system is coming down for administration.  Please wait.
Unmounting remote filesystems: /vol nfs done.
Jul 14 13:59:15 earth /usr/sbin/vold[376]: problem unmounting /vol;
Print services stopped.
Jul 14 13:59:16 earth syslogd: going down on signal 15
Killing user processes: done.

INIT: SINGLE USER MODE

Type control-d to proceed with normal startup,
(or give root password for system maintenance): xxx
Entering System Maintenance Mode ...
# 

SPARC: Example--Bringing a System to Run Level 0 (Server)

In the following example, the shutdown command is used to bring a SPARC based system to run level 0 in 5 minutes without requiring additional confirmation.


# who
root       console      Jul 14 14:01
rimmer     pts/0        Jul 14 14:03    (starbug)
pmorph     pts/1        Jul 14 14:04    (bluemidget)
# shutdown -i0 -g300 -y
Shutdown started.    Wed Jul 14 14:05:03 MDT 1999

Broadcast Message from root (console) on earth Wed Jul 14 14:05:03...
The system earth will be shut down in 5 minutes 
.
.
.
Changing to init state 0 - please wait
# 
INIT: New run level: 0
The system is coming down.  Please wait.
System services are now being stopped.
.
.
.
The system is down.
syncing file systems... done
Program terminated
Type  help  for more information
ok 

See "How to Turn Off Power to All Devices" if you are bringing the system to run level 0 to turn off power to all devices.

SPARC: Example--Rebooting a System to Run Level 3 (Server)

In the following example, the shutdown command is used to reboot a SPARC based system to run level 3 in two minutes without requiring additional confirmation.


# who
root       console      Jul 14 14:14
rimmer     pts/0        Jul 14 14:15    (starbug)
pmorph     pts/1        Jul 14 14:15    (bluemidget)
# shutdown -i6 -g120 -y
Shutdown started.    Wed Jul 14 14:16:08 MDT 1999

Broadcast Message from root (console) on earth Wed Jul 14 14:16:08...
The system earth will be shut down in 2 minutes 
.
.
.
Changing to init state 6 - please wait
# 
INIT: New run level: 6
The system is coming down.  Please wait.
.
.
.
The system is down.
syncing file systems... done
rebooting...
.
.
.
earth console login:

Where to Go From Here

Regardless of the reason for shutting down the system, you'll probably want to return to run level 3 where all file resources are available and users can log in. See Chapter 10, SPARC: Booting a System (Tasks) or Chapter 11, IA: Booting a System (Tasks) for instructions on bringing a system back to a multiuser state.

How to Shut Down a Standalone System

  1. Become superuser.

  2. Shut down the system by using the init(1M) command.


    # init run-level
    

    run-level

    Identifies the new run level. 

  3. Use the following table to verify the system is at the run level specified in the init command.

    If the System Was Brought To ... 

    The SPARC Based System Prompt Should Be ... 

    The IA Based System Prompt Should Be ... 

    Run level S (single-user state) 

    ##

    Run level 2 (multiuser state) 

    ##

    Run level 0 (power-down state) 

    ok or >type any key to continue

    Run level 3 (multiuser state with remote resources shared) 

    hostname console login:

    hostname console login:

IA: Example--Bringing a System to Run Level 0 (Standalone)

In the following example, the init command is used to bring an IA based standalone system to the level where it is safe to turn off power.


# init 0
#
INIT: New run level: 0
The system is coming down.  Please wait.
.
 
.
 
.
The system is down.
syncing file systems... [11] [10] [3] done
Type any key to continue

See "How to Turn Off Power to All Devices" if you are bringing the system to run level 0 to turn off power to all devices.

SPARC: Example--Bringing a System to Run Level S (Standalone)

In the following example, the init is used to bring a SPARC based standalone system to run level S (single-user state).


# init s
#
INIT: New run level: S
The system is coming down for administration.  Please wait.
Unmounting remote filesystems: /vol nfs done.
Print services stopped.
syslogd: going down on signal 15
Killing user processes: done. 
INIT: SINGLE USER MODE
Type Ctrl-d to proceed with normal startup,
(or give root password for system maintenance): xxx
Entering System Maintenance Mode
# 

Where to Go From Here

Regardless of the reason for shutting down the system, you'll probably want to return to run level 3 where all file resources are available and users can log in. See Chapter 10, SPARC: Booting a System (Tasks) or Chapter 11, IA: Booting a System (Tasks) for instructions on bringing a system back to a multiuser state.

How to Turn Off Power to All Devices

  1. Use the following table to determine which procedure to use for shutting down the system.

    If You Are Shutting Down a Server ... 

    If You Are Shutting Down a Standalone System ... 

    See "How to Shut Down a Server".

    See "How to Shut Down a Standalone System".

  2. Turn off power to all devices after the system is shutdown. If necessary, also unplug the power cables.

  3. After power can be restored, use the following steps to turn on the system and devices.

    1. Plug in the power cables.

    2. Turn on the monitor.

    3. Turn on disk drives, tape drives, and printers.

    4. Turn on the CPU.

      The system is brought to run level 3 after the CPU is turned on.