Inom
Hitta mer dokumentation
Supportresurser som ingår
| Ladda ner denna bok i PDF
Shutting Down a System
7
- 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 the available run levels, see Chapter 6, "Run Levels and Boot Files."
When to Shut Down the System
- The Solaris system 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:
-
- Adding or removing hardware
- Preparing for an expected power outage
- Performing file system maintenance, such as a backup
- See Chapter 5, "Overview of Shutting Down and Booting a System" for a complete list of system administration tasks requiring a system shutdown.
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 8, "Booting a SPARC System," or Chapter 9, "Booting an x86 System," for instructions on system recovery techniques.
-
Note - There is no clean way to bring a system to run level 2 or S from run level 3 (multiuser state with NFS resources shared). The best way to bring a system to an intermediate run level is to bring the system to run level 0, and then boot the system to run level S.
-
Table 7-1 describes the various shut down commands and provides recommendations for using them.
-
Table 7-1
| 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
{0,1,2,3,6,S,s}
| 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:
-
- Replace or add hardware
- Move the system from one location to another
- Prepare for an expected power outage or natural disaster like an approaching electrical storm
- All system devices 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, it will notify all logged-in users and all systems that are mounting resources from it of the impending shutdown with a warning and then a final message.
- This is why the shutdown command is recommended over the init command when used on a server. When using either command, you may want to give users more notice by sending a mail message about any scheduled system shut down.
- Use the who 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 page 119.
· How to Determine Who is Logged in to a System
-
-
Log into the system to be shut down.
-
Display logged-in users with the who command.
-
Example--Determining Who Is Logged in to a System
- The following example displays the output of the who command.
-
$ who
(1) hollyconsole (2) Jul 31 08:04 (3)
(4) kryten pts/0 Jul 28 10:04(starbug)
lister pts/1 Jul 31 08:42(bluemidget)
|
- In this example,
(1)
Identifies the username 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
-
-
Become root.
-
Find out if users are logged into the system.
-
- A list of all logged-in users is displayed. You may want to send mail or broadcast a message to let users know that the system is being shut down.
-
-
Shut down the system by using the shutdown command.
-
# shutdown -iinit-state -ggrace-period -y
|
- In this command,
-
| -iinit-state | Allows you to bring 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. |
-
-
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.
-
-
Type the root password, if prompted.
-
Type Ctrl-d to proceed with normal startup,
(or give root password for system maintenance): xxx
|
-
-
After you have finished the system administration tasks, press Control-d to return to the default run system level.
Verification--Shutting Down a Server
- 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 System Prompt Should Be ... | The x86 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: |
Example--Bringing a SPARC System to Run Level S
- In the following example, the shutdown and boot commands are used to bring a SPARC system to run level S (single-user state) in 3 minutes.
-
# who
root console Aug 1 08:35
# shutdown -i0 -g180 -y
Shutdown started. Tue Aug 1 08:39:17 MDT 1995
Broadcast Message from root (console) on mars Tue Aug 1 08:39:18
The system will be shut down in 1 minute
Broadcast Message from root (console) on mars Tue Aug 1 08:39:50
The system will be shut down in 30 seconds
.
.
.
INIT: New run level: 0
The system is coming down. Please wait.
syncing file systems... [7] [7] [5] done
Program terminated
ok boot -s
Booting from: sd(0,0,0) -s
SunOS Release 5.5 Version generic [UNIX(R) System V Release 4.0]
Copyright (c) 1983-1995, Sun Microsystems, Inc.
configuring network interfaces: le0.
Hostname: mars
INIT: SINGLE USER MODE
Type Ctrl-d to proceed with normal startup,
(or give root password for system maintenance): xxx
Entering System Maintenance Mode
#
|
Example--Bringing a SPARC System to Run Level 0
- In the following example, the shutdown command is used to bring a SPARC system to run level 0 in 5 minutes without requiring additional confirmation.
-
# who
kryten console Jul 31 16:05
rimmer pts/1 Jul 31 16:06 (starbug)
pmorph pts/2 Jul 31 16:06 (bluemidget)
Send mail message to logged-in users
# shutdown -i0 -g300 -y
Shutdown started. Fri Nov 4 11:07:33 MST 1994
Broadcast Message from root (console) on pluto Fri Nov 4 11:07:34
The system will be shut down in 3 minutes
.
.
.
INIT: New run level: 0
The system is coming down. Please wait.
.
.
.
The system is down.
syncing file systems... [11] [9] [5] done
Program terminated
Type help for more information
ok
|
- See "How to Turn Off Power to All Devices" on page 145 if you are bringing the system to run level 0 to turn off power to all devices,
Example--Rebooting a SPARC System to Run Level 3
- In the following example, the shutdown command is used to reboot a SPARC system to run level 3 in 2 minutes without requiring additional confirmation.
-
# who
kryten console Jul 31 16:05
rimmer pts/1 Jul 31 16:06 (starbug)
pmorph pts/2 Jul 31 16:06 (bluemidget)
Send mail message to logged-in users
# shutdown -i6 -g120 -y
Shutdown started. Fri Nov 4 16:10:27 MST 1994
Broadcast Message from root (console) on pluto Fri Nov 4 16:10:29
The system will be shut down in 1 minute
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... [11] [9] [5] done
rebooting...
.
.
.
pluto 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 8, "Booting a SPARC System," or Chapter 9, "Booting an x86 System," for instructions on bringing a system back to a multiuser state.
· How to Shut Down a Standalone System
-
-
Become root.
-
Shut down the system by using the init command.
-
- In this command,
-
run-level.......Identifies the new run level.
Verification--Shutting Down a Standalone System
- 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 System Prompt Should Be ... | The x86 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 resource shared) | hostname console login: | hostname console login: |
Example--Bringing an x86 System to Run Level 0
- In the following example, the init command is used to bring an x86 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" on page 145 if you are bringing the system to run level 0 to turn off power to all devices.
Example--Bringing a SPARC System to Run Level S
- In the following example, the init and boot commands are used to bring a SPARC system to run level S (single-user state).
-
# init 0
#
INIT: New run level: 0
The system is coming down. Please wait.
.
.
.
syncing file systems... [7] [7] [5] done
Program terminated
ok boot -s
Booting from: sd(0,0,0) -s
SunOS Release 5.5 Version generic [UNIX(R) System V Release 4.0]
Copyright (c) 1983-1994, Sun Microsystems, Inc.
configuring network interfaces: le0.
Hostname: venus
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 8, "Booting a SPARC System," or Chapter 9, "Booting an x86 System," for instructions on bringing a system back to a multiuser state.
· How to Turn Off Power to All Devices
-
-
Use the following table to determine which procedure to use for shutting down the system.
-
-
-
Turn off power to all devices after the system is shutdown. If necessary, also unplug the power cables.
-
After power can be restored, use the following steps to turn on the system and devices.
a. Plug in the power cables. b. Turn on the monitor.
c. Turn on disk drives, tape drives, and printers. d. Turn on the CPU.
The system to brought to run level 3 after the CPU is turned on.
|
|