Linux命令(35)之shutdown
  wwLZeziuqjLR 2023年11月02日 36 0

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:\~]$

虚机关机现象截图:

-->

Linux命令(35)之shutdown_重启

 -->

Linux命令(35)之shutdown_重启_02

只能在VMware界面,进行"再次"关机动作

Linux命令(35)之shutdown_服务器_03

3.shutdown -P now是关闭电源操作


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  Yoru5qB4TSKM   2023年12月10日   39   0   0 服务器重启IP