进行之前,需要执行将资料同步写入硬碟中的指令∶ sync
shutdown
shutdown 以讯号通知 init, 要求 init 要切换 runlevel, 来达成上述目的.
如果是关机(halt), 则切换到 runlevel 0; 若是重新开机(reboot), 则切换到 runlevel 6; 若是单人模式(single), 则切换到 runlevel 1.
然後就交给相关 runlevel 中的 script档, 完成最後的关机事项.
runlevel 的定义情形, 可参考 /etc/inittab.
[root@localhost gcc-4.1.2]# shutdown --help
shutdown: invalid option -- -
Usage: shutdown [-akrhHPfnc] [-t secs] time [warning message]
-a: use /etc/shutdown.allow
-k: don't really shutdown, only warn.
-r: reboot after shutdown.
-h: halt after shutdown.
-P: halt action is to turn off power.
-H: halt action is to just halt.
-f: do a 'fast' reboot (skip fsck).
-F: Force fsck on reboot.
-n: do not go through "init" but go down real fast.
-c: cancel a running shutdown.
-t secs: delay between warning and kill signal.
** the "time" argument is mandatory! (try "now") **
中文解释
-t 秒数 : 设定在切换至不同的runlevel之前, 警告和删除二讯号之间的延迟时间(秒).
-k : 仅送出警告讯息文字, 但不是真的要 shutdown.
-r : shutdown 之後重新开机.
-h : shutdown 之後关机.
-n : 不经过 init , 由 shutdown 指令本身来做关机动作.(不建议你用)
-f : 重新开机时, 跳过 fsck 指令, 不检查档案系统.
-F : 重新开机时, 强迫做 fsck 检查.
-c : 将已经正在 shutdown 的动作取消.
shutdown -h 10 'I will shutdown after 10 mins'
10分钟后,显示一条消息(I will shutdown after 10 mins),并执行关机
如果运行shutdown,不加任何参数,会进入单人单机模式
reboot
reboot 其实与 shutdown -r now 几乎相同
halt 与 poweroff 也具有相同的功能(关机)!
开关机
猜你喜欢
转载自liyixing1.iteye.com/blog/1013508
今日推荐
周排行