# who
屏幕上会显示所有登录用户的列表。
# shutdown -iinit-state -ggrace-period -y
使系统进入到与缺省级别 S 不同的 init 状态。选项包括 0、1、2、5 和 6。
运行级别 0 和 5 是为关闭系统而保留的状态。运行级别 6 用于重新引导系统。运行级别 2 可用作多用户操作状态。
指示系统关闭前的时间(以秒为单位)。缺省值为 60 秒。
继续关闭系统,无需任何介入。否则,系统会提示您在 60 秒后继续执行关闭过程。
有关更多信息,请参见 shutdown(1M) 手册页。
Do you want to continue? (y or n): y
如果使用了 shutdown -y 命令,系统将不提示您继续操作。
Type Ctrl-d to proceed with normal startup, (or give root password for system maintenance): xxxxxx
|
在以下示例中,使用 shutdown 命令使系统在三分钟内进入运行级别 S(单用户状态)。
# who root console Apr 15 06:20 # shutdown -g180 -y Shutdown started. Fri Apr 15 06:20:45 MDT 2014 Broadcast Message from root (console) on portia Fri Apr 15 06:20:46... The system portia will be shut down in 3 minutes showmount: portia: RPC: Program not registered Broadcast Message from root (console) on portia Fri Apr 15 06:21:46... The system portia will be shut down in 2 minutes showmount: portia: RPC: Program not registered Broadcast Message from root (console) on portia Fri Apr 15 06:22:46... The system portia will be shut down in 1 minute showmount: portia: RPC: Program not registered Broadcast Message from root (console) on portia Fri Apr 15 06:23:16... The system portia will be shut down in 30 seconds showmount: portia: RPC: Program not registered Changing to init state s - please wait svc.startd: The system is coming down for administration. Please wait. root@portia:~# Apr 15 06:24:28 portia svc.startd[9]: Apr 15 06:24:28 portia syslogd: going down on signal 15 svc.startd: Killing user processes. Requesting System Maintenance Mode (See /lib/svc/share/README for more information.) SINGLE USER MODE Enter user name for system maintenance (control-d to bypass):xxxxxx #示例 3-2 使用 shutdown 命令使系统进入关闭状态(运行级别 0)
在以下示例中,使用 shutdown 命令使系统在五分钟内进入运行级别 0,而无需进行其他确认操作。
# who root console Jun 17 12:39... userabc pts/4 Jun 17 12:39 (:0.0) # shutdown -i0 -g300 -y Shutdown started. Fri Apr 15 06:35:48 MDT 2014 Broadcast Message from root (console) on murky Fri Apr 15 06:35:48... The system pinkytusk will be shut down in 5 minutes showmount: murkey: RPC: Program not registered showmount: murkey: RPC: Program not registered Broadcast Message from root (console) on murkey Fri Apr 15 06:38:48... The system murkey will be shut down in 2 minutes showmount: murkey: RPC: Program not registered Broadcast Message from root (console) on murkey Fri Apr 15 06:39:48... The system murkey will be shut down in 1 minute showmount: murkey: RPC: Program not registered Broadcast Message from root (console) on murkey Fri Apr 15 06:40:18... The system murkey will be shut down in 30 seconds showmount: murkey: RPC: Program not registered Broadcast Message from root (console) on murkey Fri Apr 15 06:40:38... THE SYSTEM murkey IS BEING SHUT DOWN NOW ! ! ! Log off now or risk your files being damaged showmount: murkey: RPC: Program not registered Changing to init state 0 - please wait root@murkey:~# svc.startd: The system is coming down. Please wait. svc.startd: 122 system services are now being stopped. Apr 15 06:41:49 murkey svc.startd[9]: Apr 15 06:41:50 murkey syslogd: going down on signal 15 svc.startd: Killing user processes. Apr 15 06:41:57 The system is down. Shutdown took 69 seconds. syncing file systems... done Press any key to reboot. Resetting...
如果要使系统进入运行级别 0 以关闭所有设备的电源,请参见关闭系统设备电源。
示例 3-3 使用 shutdown 命令使系统进入多用户状态(运行级别 3)在以下示例中,使用 shutdown 命令在两分钟内将系统重新引导至运行级别 3。不需要进行其他确认。
# who root console Jun 14 15:49 (:0) userabc pts/4 Jun 14 15:46 (:0.0) # shutdown -i6 -g120 -y Shutdown started. Fri Apr 15 06:46:50 MDT 2014 Broadcast Message from root (console) on venus Fri Apr 15 06:46:50... The system venus will be shut down in 2 minutes Broadcast Message from root (console) on venus Fri Apr 15 06:47:50... The system venus will be shut down in 1 minute Broadcast Message from root (console) on venus Fri Apr 15 06:48:20... The system venus will be shut down in 30 seconds Broadcast Message from root (console) on venus Fri Apr 15 06:48:40... THE SYSTEM venus IS BEING SHUT DOWN NOW ! ! ! Log off now or risk your files being damaged showmount: venus: RPC: Program not registered Changing to init state 6 - please wait root@venus:~# svc.startd: The system is coming down. Please wait. svc.startd: 123 system services are now being stopped. Apr 15 06:49:32 venus svc.startd[9]: Apr 15 06:49:32 venus syslogd: going down on signal 15 svc.startd: Killing user processes. Apr 15 06:49:40 The system is down. Shutdown took 50 seconds. syncing file systems... done rebooting... SunOS Release 5.11 Version 11.2 64-bit Copyright (c) 1983, 2014, Oracle and/or its affiliates. All rights reserved. Booting to milestone "milestone/single-user:default". Hostname: venus NIS domain name is solaris.example.com . . . venus console login:
另请参见
无论您为何关闭系统,您都可能希望返回运行级 3,在该级别下所有的文件资源都可用且用户可以登录。有关将系统恢复到多用户状态的说明,请参见Chapter 4, 引导系统(任务)。