shutdown [-akrhPHfFnc] [-t sec] time [message]
选件
-a
|
使用控制访问文件/etc/shutdown.allow来控制对shutdown命令的访问。有关更多信息,请参见下面的访问控制。
|
-k
|
不要关闭,而是像关闭一样发送警告消息。
|
-r
|
shutdow后重新启动。
|
-h
|
指示系统关闭然后停止。
|
-P
|
指示系统关闭然后关闭电源。
|
-H
|
如果还指定了-h,则此选项指示系统放入支持它的系统上的引导监视器。
|
-f
|
重启后跳过fsck。
|
-F
|
重启后强制执行fsck。
|
-n
|
不要调用init来关闭进程;指示shutdow自行执行此操作。
不鼓励使用此选项,并且其结果并非总是可预测的。
|
-c
|
取消挂起的shutdow。(这不适用于“立即关闭”,后者不会在关闭之前等待。)使用此选项,无法给出时间参数,但是您仍然可以指定一条说明性消息,该消息将发送给所有用户。
|
-t sec
|
给init等待秒发送过程的警告和秒之间杀信号,改变到另一个运行级别之前。
|
time
|
在时间参数指定何时执行shutdow操作。
的时间可以不同的方式被格式化:
首先,它可以在格式的绝对时间HH :毫米,其中HH表示小时(1或2位,从0至23)和毫米表示小时的分钟(两位数)。
其次,它可以采用+ m的格式,其中m是等待的分钟数。
另外,单词现在与指定+0相同;它会立即关闭系统。
|
信息
|
将发送给所有用户的消息以及标准关闭通知。
|
细节
如果计划在将来shutdown,它将创建咨询文件/ etc / nologin,这将导致诸如login之类的程序不允许新用户登录。该文件是在关闭顺序开始前五分钟创建的。如果该文件在发出启动信号之前已停止(即已取消或出现问题),则shutdown会删除该文件。它还会在调用init更改运行级别之前将其删除。
在-f标志的意思是“快速重启”。这只会创建一个咨询文件/ fastboot,当再次出现该文件时,系统可以对其进行测试。系统引导rc文件(“ rc”代表“ runcom”,是“ run命令”的缩写)可以测试该文件是否存在,并决定不运行fsck,因为系统已通过正确的方式关闭了。之后,引导过程应删除/ fastboot。
该-F标志的意思是“力量的fsck ”。这只会创建一个咨询文件/ forcefsck,再次出现该文件时,系统可以对其进行测试。引导rc文件可以测试该文件是否存在,并决定使用特殊的“ force”标志运行fsck,以便甚至检查正确卸载的文件系统。之后,引导过程应删除/ forcefsck。
该-n标志导致shutdow不调用初始化,但杀死所有正在运行的进程本身。然后shutdown将关闭quota,accounting和交换并卸载所有文件系统。
访问控制
如果在/ etc / inittab中存在适当的条目,则可以在按下Ctrl + Alt + Del组合键时从init调用shutdown。但是,这意味着可以物理访问控制台键盘的每个人都可以关闭系统。
为了防止这种情况,shutdow可以检查,看看是否被授权的用户登录,如果shutdow时调用-a参数(这个增加的调用关闭在/ etc / inittab中),它会检查该文件在/ etc /shutdown.allow存在。然后,它将该文件中的登录名与在虚拟控制台上登录的人员列表进行比较(来自/ var / run / utmp)。仅当这些授权用户或root用户之一登录时,它才会继续。否则,它将写消息
关闭:没有授权用户登录
...到(物理)系统控制台。/etc/shutdown.allow的格式是每行一个用户名。允许使用空行和注释行(以#开头)。目前,此文件中的用户数限制为32。
请注意,如果不存在/etc/shutdown.allow,则-a参数将被忽略。
停止与关机
该-H选项仅设置init 环境变量 INIT_HALT到HALT,和-P选项只是设置该变量POWEROFF。在关闭序列中最后一个调用halt的关闭脚本应该检查这些环境变量,并使用正确的选项调用halt,以使这些选项真正生效。
档案
/ fastboot
/ etc / inittab
/etc/init.d/halt
/etc/init.d/reboot
/etc/shutdown.allow
shutdown [-akrhPHfFnc] [-t sec] time [message]
Options
-a
|
Control access to the shutdown command using the control access file /etc/shutdown.allow. See Access Control below for more information.
|
-k
|
Do not shut down, but send the warning messages as if the shutdown were real.
|
-r
|
Reboot after shutdown.
|
-h
|
Instructs the system to shut down and then halt.
|
-P
|
Instructs the system to shut down and then power down.
|
-H
|
If -h is also specified, this option instructs the system to drop into boot monitor on systems that support it.
|
-f
|
Skip fsck after reboot.
|
-F
|
Force fsck after reboot.
|
-n
|
Don't call init to do the shutdown of processes; instruct shutdown to do that itself.
The use of this option is discouraged, and its results are not always predictable.
|
-c
|
Cancel a pending shutdown. (This does not apply to "shutdown now", which does not wait before shutting down.) With this option, it is not possible to give the time argument, but you can still specify an explanatory message that will be sent to all users.
|
-t sec
|
Tell init to wait sec seconds between sending processes the warning and the kill signal, before changing to another runlevel.
|
time
|
The time argument specifies when to perform the shutdown operation.
The time can be formatted in different ways:
First, it can be an absolute time in the format hh:mm, in which hh is the hour (1 or 2 digits, from 0 to 23) and mm is the minute of the hour (in two digits).
Second, it can be in the format +m, in which m is the number of minutes to wait.
Also, the word now is the same as specifying +0; it shuts the system down immediately.
|
message
|
A message to be sent to all users, along with the standard shutdown notification.
|
Details
If a shutdown is scheduled for the future, it will create the advisory file /etc/nologin which causes programs such as login not to allow new user logins. This file is created five minutes before the shutdown sequence starts. shutdown removes this file if it is stopped before it can signal init (i.e. it is cancelled or something goes wrong). It also removes it before calling init to change the runlevel.
The -f flag means "reboot fast". This only creates an advisory file /fastboot which can be tested by the system when it comes up again. The system boot rc file ("rc" stands for "runcom", which is short for "run commands") can test if this file is present, and decide not to run fsck since the system has been shut down in the proper way. After that, the boot process should remove /fastboot.
The -F flag means "force fsck". This only creates an advisory file /forcefsck which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide to run fsck with a special "force" flag so that even properly unmounted file systems get checked. After that, the boot process should remove /forcefsck.
The -n flag causes shutdown not to call init, but to kill all running processes itself. shutdown will then turn off quota, accounting, and swapping and unmount all file systems.
Access Control
shutdown can be called from init when the Ctrl+Alt+Del key combination is pressed, if there exists an appropriate entry in /etc/inittab. This would mean that everyone who has physical access to the console keyboard can shut the system down, however.
To prevent this, shutdown can check to see if an authorized user is logged in. If shutdown is called with the -a argument (add this to the invocation of shutdown in /etc/inittab), it checks to see if the file /etc/shutdown.allow is present. It then compares the login names in that file with the list of people that are logged in on a virtual console (from /var/run/utmp). Only if one of those authorized users or root is logged in, it will proceed. Otherwise, it will write the message
shutdown: no authorized users logged in
...to the (physical) system console. The format of /etc/shutdown.allow is one username per line. Empty lines and comment lines (prefixed by a #) are allowed. Currently there is a limit of 32 users in this file.
Note that if /etc/shutdown.allow is not present, the -a argument is ignored.
Halting vs. Powering Off
The -H option just sets the init environment variable INIT_HALT to HALT, and the -P option just sets that variable to POWEROFF. The shutdown script that calls halt as the last thing in the shutdown sequence should check these environment variables and call halt with the right options for these options to actually have any effect.
Files
/fastboot
/etc/inittab
/etc/init.d/halt
/etc/init.d/reboot
/etc/shutdown.allow