shutdown是我们在linux关机是常用的指令,学会这个指令将让我们更加正确的去关机!
通过阅读man shutdown我们知道:
shutdown may be used to halt, power-off or reboot the machine.
shutdown就是关机和重启的的功能,那么我们怎么操作呢?
1、命令格式
常用: shutdown [-hr等] 时间 [关机信息] 其它: shutdown [-c]
2,操作如下:
--help
Prints a short help text and exits.
-H, --halt
Halt the machine.
-P, --poweroff
Power-off the machine (the default).
-r, --reboot
Reboot the machine.
-h
Equivalent to --poweroff, unless --halt is specified.
-k
Do not halt, power-off, reboot, just write wall message.
--no-wall
Do not send wall message before halt, power-off, reboot.
-c
Cancel a pending shutdown. This may be used cancel the effect of an invocation of shutdown
with a time argument that is not "+0" or "now".
3,举例说明:
[root@www ~]# shutdown -h now
立刻关机,其中 now 相当于时间为 0 的状态
[root@www ~]# shutdown -h 20:25
系统在今天的 20:25 分会关机,若在21:25才下达此命令,则隔天才关机
[root@www ~]# shutdown -h +10
系统再过十分钟后自动关机
[root@www ~]# shutdown -r now
系统立刻重新启动
[root@www ~]# shutdown -r +30 'The system will reboot'
再过三十分钟系统会重新启动,并显示后面的信息给所有在在线的使用者
[root@www ~]# shutdown -k now 'This system will reboot'
仅发出警告信件的参数!系统并不会关机啦!吓唬人!