Linux命令之shutdown
1.shutdown介绍
linux命令shutdown主要用来重启、关闭服务器。
2.shutdown用法
shutdown [参数]
shutdown常用参数
参数 说明
-c 取消即将执行的关机程序
-k
仅仅向每个登录用户发出警告信息,并不真正关机
-h 关机(halt)
-H 关机(halt)
-P 关机(poweroff)
-r 重启(reboot)
--help
shutdown帮助信息
3.实例
3.1.立即关机
命令:
shutdown -H now
OR
shutdown -h now
OR
shutdown -P now
OR
init 0
OR
poweroff
3.2.立即重启
命令:
shutdown -r now
OR
reboot
OR
init 6
3.3.30分钟后关机,并给出提示信息
命令:
shutdown -h +30 "The system will poweroff"
[root@rhel77 ~]# shutdown -h +30 "The system will poweroff"
Shutdown scheduled for Tue 2023-06-13 11:33:48 CST, use 'shutdown -c' to cancel.
[root@rhel77 ~]#
使用shutdown -c可以取消上述动作
[root@rhel77 ~]# shutdown -h +30 "The system will poweroff"
Shutdown scheduled for Tue 2023-06-13 11:33:48 CST, use 'shutdown -c' to cancel.
[root@rhel77 ~]#
[root@rhel77 ~]# shutdown -c
Broadcast message from root@rhel77 (Tue 2023-06-13 11:04:30 CST):
The system shutdown has been cancelled at Tue 2023-06-13 11:05:30 CST!
[root@rhel77 ~]#
3.4.仅发出警告,系统不会关机
命令:
shutdown -k now "testing,haha"
[root@rhel77 ~]# shutdown -k now 'testing,haha'
[root@rhel77 ~]#
3.5.查看shutdown帮助信息
命令:
shutdown --help
[root@rhel77 ~]# shutdown --help
shutdown [OPTIONS...] [TIME] [WALL...]
Shut down the system.
--help Show this help
-H --halt Halt the machine
-P --poweroff Power-off the machine
-r --reboot Reboot the machine
-h Equivalent to --poweroff, overridden by --halt
-k Don't halt/power-off/reboot, just send warnings
--no-wall Don't send wall message before halt/power-off/reboot
-c Cancel a pending shutdown
[root@rhel77 ~]#
3.6.shutdown -h now、shutdown -H now、shutdown -P now的区别
1.shutdown -h now则根据系统的默认设置来选择是否关闭电源
2.shutdown -H now是关机操作,系统停止运行,但并未关闭电源 --可以vmware构建的虚机中运行此命令,进行观察,不建议使用此命令
[root@rhel77 ~]# shutdown -H now
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(192.168.10.137:22) at 11:13:49.
Type `help' to learn how to use Xshell prompt.
[C:~]$
虚机关机现象截图:
-->
-->
只能在VMware界面,进行"再次"关机动作
3.shutdown -P now是关闭电源操作
————————————————
版权声明:本文为CSDN博主「小黑要上天」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/z19861216/article/details/131183849