the shutdown command in linux for shutdown in time or reboot

命令简介:

该命令可以安全关闭或者重新启动系统。你没有看错,shutdown命令不仅可以关闭系统、也可以重启Linux系统。


命令参数:

参数

长参数

描叙

-a

扫描二维码关注公众号,回复: 3787723 查看本文章

Use /etc/shutdown.allow.

-c

中断关机:当执行"shutdown -h 12:00"指令时,只要按+键就可以中断关机的指令

-f

重新启动时不进行磁盘检测(fsck)

-F

重新启动时进行磁盘检测(fsck)

-h

关闭电源

-k

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

-n

不调用init进程进行关机,而是强行关机

-r

关闭系统然后重新启动,类似于Windows平台restart

-t

延迟关机的时间

-w

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

--help

显示命令在线帮助




1. look the shutdown help information:

点击(此处)折叠或打开

  1. Usage: shutdown [OPTION]... TIME [MESSAGE]
  2. Bring the system down.

  3. Options:
  4.   -r reboot after shutdown
  5.   -h halt or power off after shutdown
  6.   -H halt after shutdown (implies -h)
  7.   -P power off after shutdown (implies -h)
  8.   -c cancel a running shutdown
  9.   -k only send warnings, don't shutdown
  10.   -q, --quiet reduce output to errors only
  11.   -v, --verbose increase output to include informational messages
  12.       --help display this help and exit
  13.       --version output version information and exit

  14. TIME may have different formats, the most common is simply the word 'now

2:马上关闭Linux系统,其中 now 相当于时间为 0 的状态

点击(此处)折叠或打开

  1. shutdown -h now

3:系统2分钟后重新启动,其中+m表示几分钟后关机或开机。

点击(此处)折叠或打开

  1. shutdown -r +2

4:设置系统在那个时间点关机

点击(此处)折叠或打开

  1. shutdown -h 12:30
    or

点击(此处)折叠或打开

  1. shutdown -h 12:30 &

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

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

5:将前一个shutdown命令取消息

点击(此处)折叠或打开

  1. shutdown -c
    or
keys : ctrl+C

猜你喜欢

转载自blog.csdn.net/warrior_zhang/article/details/50503389