System Administration Guide: Basic Administration

Chapter 12 Shutting Down a System (Tasks)

This chapter describes the procedures for shutting down systems. This is a list of the step-by-step instructions in this chapter.

This is a list of the overview information in this chapter.

For overview information about system run levels, see Chapter 11, Run Levels and Boot Files (Tasks).

Shutting Down the System

Solaris software is designed to run 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. In some cases, the system needs to be brought to an intermediate level, where not all system services are available, such as the following:

For a complete list of system administration tasks that require a system shutdown, see Chapter 10, Shutting Down and Booting a System (Overview).

For information on using your system's power management features, see Solaris Common Desktop Environment: User's Guide.

System Shutdown Commands

The use of 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 that all file system changes are written to the disk, and all system services, processes, and the operating system are terminated normally.

The use of 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, it is sometimes necessary to use these actions in emergency situations. For instructions on system recovery techniques, see Chapter 13, SPARC: Booting a System (Tasks) or Chapter 14, IA: Booting a System (Tasks).

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

Table 12–1 Shutdown Commands

Command 

Description 

When To Use 

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. Also notified are the systems that are mounting resources from the server that is being shut down.  

init

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

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

reboot

An executable that syncs the disks and passes boot 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. This script stops all processes, syncs the disks, and unmounts any remaining file systems.

User Notification of System Down Time

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

For this reason, the shutdown command is recommended over the init command when you need to shut down a server. When you use either command, you might want to give users more notice by sending them 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. See 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.


    $ who
    

Example—Determining Who Is Logged in to a System

The following example shows how to display who is logged in to the system.


$ 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 that 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

Use this procedure when you need to shut down a server.

  1. Become superuser.

  2. Find out if users are logged in to 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.


    # shutdown -iinit-level -ggrace-period -y
    

    -iinit-level

    Brings the system to an init level that is 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. 

    For more information, see shutdown(1M).

  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 system run level.

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

    Specified Run Level 

    SPARC System Prompt 

    IA System Prompt 

    S (single-user level) 

    0 (power-down level) 

    ok or >

    type any key to continue

    Run level 3 (multiuser level with remote resources shared) 

    hostname console login:

    hostname console login:

SPARC: Example—Bringing a Server to Run Level S

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


# who
root       console      Dec 13 14:30
# shutdown -g180 -y

Shutdown started.    Thu Dec 13 14:30:32 MST 2001

Broadcast Message from root (console) on earth Thu Dec 13 14:30:33...
The system earth will be shut down in 3 minutes 
.
.
.
Broadcast Message from root (console) on earth Thu Dec 13 14:30:33...
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.
Shutting down Solaris Management Console server on port 898.
Print services stopped.
Dec 13 14:34:00 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 Server to Run Level 0

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      Dec 12 08:08
rimmer     pts/0        Dec 11 14:48    (starbug)
pmorph     pts/1        Dec 13 12:31    (bluemidget)
# shutdown -i0 -g300 -y
Shutdown started.    Thu Dec 13 14:51:39 MST 2001

Broadcast Message from root (console) on earth Thu Dec 13 14:51:39...
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 

If you are bringing the system to run level 0 to turn off power to all devices, see How to Turn Off Power to All Devices.

SPARC: Example—Rebooting a Server to Run Level 3

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      Dec 12 08:08
rimmer     pts/0        Dec 11 14:48    (starbug)
pmorph     pts/1        Dec 13 12:31    (bluemidget)
# shutdown -i6 -g120 -y
Shutdown started.    Thu Dec 13 15:56:30

Broadcast Message from root (console) on earth Thu Dec 13 15:56:30...
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 why you shut down a system, you'll probably want to return to run level 3 where all file resources are available and users can log in. For instructions on bringing a system back to a multiuser level, see Chapter 13, SPARC: Booting a System (Tasks) or Chapter 14, IA: Booting a System (Tasks).

How to Shut Down a Standalone System

Use this procedure when you need to shut down a standalone system.

  1. Become superuser.

  2. Shut down the system.


    # init run-level
    

    run-level identifies the new run level.

    For more information, see init(1M).

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

    Specified Run Level 

    SPARC System Prompt 

    IA System Prompt 

    S (single-user level) 

    ##

    2 (multiuser level) 

    ##

    0 (power-down level) 

    ok or >type any key to continue

    3 (multiuser level with NFS resources shared) 

    hostname console login:

    hostname console login:

x86: Example—Bringing a Standalone System to Run Level 0

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

If you are bringing the system to run level 0 to turn off power to all devices, see How to Turn Off Power to All Devices.

SPARC: Example—Bringing a Standalone System to Run Level S

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


# 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 why you shut down the system, you'll probably want to return to run level 3 where all file resources are available and users can log in. For instructions on bringing a system back to a multiuser level, see Chapter 13, SPARC: Booting a System (Tasks) or Chapter 14, IA: Booting a System (Tasks).

Turning Off Power to All Devices

You need turn off power to all system devices is when you do the following:

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

Before you turn off power to all system devices, you should shutdown the system cleanly, as described in the preceding sections.

How to Turn Off Power to All Devices

  1. Select one of the following to shut down the system.

    1. If shutting down a server, see How to Shut Down a Server.

    2. If shutting down a standalone system, see How to Shut Down a Standalone System.

  2. Turn off the 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.