linux怎么撤销关机命令,一天一个Linux基础命令之关机命令shutdown

关机重启命令shutdown

1、命令格式

shutdown[options] [+]TIME

2、命令功能

shutdown命令可以安全地关闭或重启,它在系统关闭之前给系统上的所有登录用户提示一条警告信息,系统在指定时间关机之前的5分钟会通知所有用户,系统马上就要关机了,在这5分钟之内,新登录的用户禁止登录。

该命令还允许用户指定一个时间参数,可以是一个精确的时间,也可以是从现在开始的一个时间段。

时间格式:

now:现在

+#:在多少分钟后关机

hh:mm:再指定的时间关机、指定的是24小时格式的

3、命令参数

-r:系统重新启动

-h:系统关机

-P:关闭系统后关闭电源

-k:模拟关机(不是真的关机),只是向登录者发送警告信息出去!

4、常用实例

1、马上关闭Linux系统

命令:shutdown -h now[root@server~]# shutdown -h now

Broadcastmessage from root@server

(/dev/pts/0) at 12:25 ...

Thesystem is going down for halt NOW!

2、系统在5分钟后重新启动

命令:shutdown -r +5[root@server~]# shutdown -r +5

Broadcastmessage from root@server

(/dev/pts/0) at 12:26 ...

Thesystem is going down for reboot in 5 minutes!

[root@server~]# shutdown -r +5&     //&将命令发送至后台运行

[1] 1527

[root@server~]#

Broadcastmessage from root@server

(/dev/pts/0) at 12:26 ...

Thesystem is going down for reboot in 5 minutes!

[root@server~]#

3、设定系统在哪个时间点关机或重启

命令:shutdown -h 12:00 | shutdown -r 21:30[root@server~]# date

Sat Dec24 12:30:09 CST 2016

[root@server~]# shutdown -r 12:00

Broadcastmessage from root@server

(/dev/pts/0) at 12:30 ...

Thesystem is going down for reboot in 1410 minutes!

^Cshutdown:Shutdown cancelled

[root@server~]# shutdown -r 12:00&

[1] 1544

[root@server~]#

Broadcastmessage from root@server

(/dev/pts/0) at 12:30 ...

Thesystem is going down for reboot in 1410 minutes!

[root@server~]#

最好是使用命令&将关机命令至于后台处理。不影响当前其它操作。

提示:

设置多久时间后执行shutdown命令。时间参数有hh:mm或+m两种模式。hh:mm格式表示在几点几分执行shutdown命令。例如“shutdown 12:00”表示将在12:00执行shutdown。+m表示m分钟后执行shutdown.比较特别的用法是以now表示立即执行shutdown.值得注意的是这部分参数不能省略。另外,需要注意如果现在已经22:30,你执行了shutdown -h 22:00 &那么第二天才会关机。

4、取消关机或重启命令

命令:shutdown -c[root@server~]# shutdown: Shutdown cancelled

[1]+  Done                    shutdown -r 12:00

[root@server~]#

提示:

如果命令没在后台运行,可以用CTRL+C取消命令

5、关机命令也可以在关机之前向登录的用户发送关机消息

命令:shutdown -h +5 "Systemshutdown after five minutes"&[root@server~]#

Broadcastmessage from root@server

(/dev/pts/0) at 12:38 ...

Thesystem is going down for halt in 5 minutes!

System shutdown after five minutes

[root@server~]#

halt:关机命令,调用的是shutdown -h

halt [options]...

命令参数

-f:强制关机,并不调用shutdown(8)管关机

-w:仅做测试,并不真的将系统重新开机,只会把重开机的数据写入/var/log目录下的wtmp记录文件

-p:在关机的时候顺便做下关闭电源的操作,调用poweroff命令

常用实例

halt:关机

poweroff:关闭电源命令

在关机完成后顺便把电源也给关掉

reboot:重启命令,调用的是shutdown -r

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值