Go to main content

手册页部分 8:系统管理命令

退出打印视图

更新时间: 2022年7月27日 星期三
 
 

shutdown(8)

名称

shutdown - 关闭系统,更改系统状态

用法概要

/usr/sbin/shutdown [-y] [-g grace-period] [-r | -p | -i init-state]
     [message]

描述

shutdown is executed by a system administrator to change the run level of the machine.In most cases, it is used to change from the multi-user state to another state.

shutdown must be run with an effective uid of 0, which may be provided by the Maintenance and Repair rights profile.

缺省情况下,shutdown 使系统处于只有控制台可以访问操作系统的状态。此状态称为单用户状态。

在开始关闭守护进程和终止进程之前,shutdown 会发送一条警告消息,并且缺省发送一条最终消息要求确认。message 是在标准警告消息之后发出的一个字符串:

The system will be shut down in . . .

如果该字符串包含多个词,则应放在单引号 (') 或双引号 (") 中。

警告消息和用户提供的 messageshutdown 开始之前的 7200、3600、1800、1200、600、300、120、60 和 30 秒输出。请参见“示例”部分。

系统状态的定义如下:

状态 0

停止操作系统。

状态 1

状态 1 是指管理员状态。处于状态 1 时,将挂载多用户操作所需的文件系统,并可使用需要访问多用户文件系统的登录名。当系统从固件模式进入状态 1 时,只有控制台是活动的,其他多用户(状态 2)服务不可用。请注意,在从多用户状态转换到状态 1 时,不会停止所有用户进程。

状态 s、S

状态 s(或 S)是指单用户状态。在转换到此状态时,将停止所有用户进程。处于单用户状态时,将卸载多用户登录所需的文件系统,只能通过控制台访问系统。不能使用需要访问多用户文件系统的登录名。

状态 5

关闭机器,从而安全拔下电源。如果可能,拔下机器上的电源。调用 rc0 过程以执行此任务。

state 6

停止操作系统,重新引导至 /etc/inittab 中的 initdefault 项定义的状态。调用 rc6 过程以执行此任务。

See init(8) for more information on the system run levels corresponding to these states.

选项

–y

预先回答确认问题,从而可以在无用户干预的情况下运行命令。

–g grace-period

Specify the number of seconds to wait and warn users before switching states.If this option is not used, the default is 60 seconds.

–i init-state

Specify the init-state to change to at the end of the grace period, as if ‘init init-state’ was run.By default, system state ‘s’ is used.

–r

等效于指定 –i6

–p

重新引导至 PROM。此标志可用于通过固件重新引导系统,而不会更改由 system/boot-config 服务中的 config/fastreboot_default 属性设置指定的缺省重新引导行为。

–p–i 选项互斥。

示例

示例 1 使用 shutdown

在以下示例中,shutdown 在主机 foo 上执行,并且执行时间安排在 120 秒后。在最终确认消息发出前的 2 分钟、1 分钟和 30 秒输出警告消息。

example# shutdown -i S -g 120 "===== disk replacement ====="
Shutdown started.   Tue Jun   7  14:51:40 PDT  1994

Broadcast Message from root (pts/1) on foo Tue Jun  7 14:51:41. . .
The system will be shut down in 2 minutes
===== disk replacement =====
Broadcast Message from root (pts/1) on foo Tue Jun  7 14:52:41. . .
The system will be shut down in 1 minutes
===== disk replacement =====
Broadcast Message from root (pts/1) on foo Tue Jun  7 14:53:41. . .
The system will be shut down in 30 seconds
===== disk replacement =====
Do you want to continue? (y or n):

文件

/etc/inittab

通过 init 控制进程分发

属性

有关下列属性的说明,请参见 attributes(7)

属性类型
属性值
可用性
system/core-os

另请参见

init.d(5), inittab(5), nologin(5), attributes(7), smf(7), boot(8), bootadm(8), halt(8), init(8), killall(8), reboot(8)

附注

系统向下转换为运行级别 1 或单用户(运行级别 S 或 s)时,会创建 /etc/nologin 文件(请参见 nologin(5))。后续转换为运行级别 2、3 或 4(多用户状态)时,将会删除 /etc/nologin 文件。

关闭映像时,服务将按照相反的依赖顺序关闭。