shutdown(8) System Manager’s Manual shutdown(8)
NAME
shutdown - bring the system down
SYNOPSIS
shutdown [OPTION]… TIME [MESSAGE]
DESCRIPTION
shutdown arranges for the system to be brought down in a safe way. All
logged-in users are notified that the system is going down and,within
the last five minutes of TIME,new logins are prevented.
TIME may have different formats,the most common is simply the word 'now' which will bring the system down immediately. Other valid for‐ mats are +m,where m is the number of minutes to wait until shutting down and hh:mm which specifies the time on the 24hr clock. If no option is specified,the default action is to bring the system down into single-user mode. Once TIME has elapsed,shutdown sends a request to the init(8) daemon to bring the system down into the appropriate runlevel. This is performed by emitting the runlevel(7) event,which includes the new runlevel in the RUNLEVEL environment variable as well as the previ‐ ous runlevel (obtained from the environment or from /var/run/utmp) in the PREVLEVEL variable. An additional INIT_HALT variable may be set,this will contain the value HALT when bringing the system down for halt and POWEROFF when bringing the system down for power off.
OPTIONS
-r Requests that the system be rebooted after it has been brought
down.
-h Requests that the system be either halted or powered off after it has been brought down,with the choice as to which left up to the system. -H Requests that the system be halted after it has been brought down. -P Requests that the system be powered off after it has been brought down. -c Cancels a running shutdown. TIME is not specified with this option,the first argument is MESSAGE. -k Only send out the warning messages and disable logins,do not actually bring the system down.
ENVIRONMENT
RUNLEVEL
shutdown will read the current runlevel from this environment
variable if set in preference to reading from /var/run/utmp
FILES
/var/run/utmp
Where the current runlevel will be read from; this file will
also be updated with the new runlevel.
/var/log/wtmp A new runlevel record will be appended to this file for the new runlevel.
NOTES
The Upstart init(8) daemon does not keep track of runlevels itself,
instead they are implemented entirely by its userspace tools.
See runlevel(7) for more details.
AUTHOR
Written by Scott James Remnant scott@netsplit.com
REPORTING BUGS
Report bugs at https://launchpad.net/upstart/+bugs
COPYRIGHT
Copyright © 2009 Canonical Ltd.
This is free software; see the source for copying conditions. There is
NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
SEE ALSO
runlevel(7) init(8) telinit(8) reboot(8)
Upstart 2009-07-09 shutdown(8)
以上为man shutdown 手册信息。下面看点中文的。
关机命令 shutdown
好像ubuntu的终端中默认的是当前用户的命令,只是普通用户,因此在终端器中可以使用sudo -sh 转换到管理员root用户下执行命令。
1)shutdown –help
可以查看shutdown命令如何使用,当然也可以使用man shutdown命令。
2) shutdown -h now 现在立即关机
3)shutdown -r now 现在立即重启
4)shutdown -r +3 三分钟后重启
5)shutdown -h +3 “The System will shutdown after 3 minutes” 提示使用者将在三分钟后关机
6)shutdown -r 20:23 在20:23时将重启计算机
7)shutdown -r 20:23 & 可以将在20:23时重启的任务放到后台去,用户可以继续操作终端
2中断命令
1)执行完命令后(若没有转到后台),可以使用CTRL+C来中止命令
2)kill 程序编码
当命令在后台执行时系统会返回一个程序编码,例如:在使用 shutdown -r 20:23 & 系统返回系统编码:4905
我们可以使用kill 4905来中止重启命令
3ps aux | grep 程序编号
我们如果知道程序的编号,我们可以使用ps aux |grep 程序编号来查询该程序编号对应的命令是什么。
例如上面的程序编号为4905 ,我们可以使用ps aux | grep 4905 就可以查到 shutdown -r 20:23 & 的命令
halt—-最简单的关机命令
其实halt就是调用shutdown -h。halt执行时﹐杀死应用进程﹐执行sync系统调用﹐文件系统写操作完成后就会停止内核。
参数说明:
[-n] 防止sync系统调用﹐它用在用fsck修补根分区之后﹐以阻止内核用老版本的超级块〔superblock〕覆盖修补过的超级块。
[-w] 并不是真正的重启或关机﹐只是写wtmp〔/var/log/wtmp〕纪录。
[-d] 不写wtmp纪录〔已包含在选项[-n]中〕。
[-f] 没有调用shutdown而强制关机或重启。
[-i] 关机〔或重启〕前﹐关掉所有的网络接口。
[-p] 该选项为缺省选项。就是关机时调用poweroff。