shutdown命令作用
shutdown命令安全地将系统关机。 有些使用者会使用直接断掉电源的方式来关闭linux系统,这是十分危险的。因为linux与windows不同,其后台运行着许多进程,所以强制关机可能会导致进程的数据丢失﹐使系统处于不稳定的状态﹐甚至在有的系统中会损坏硬件设备。
shutdown命令格式
1 |
shutdown [OPTIONS…] [TIME] [WALL…] |
命令参数
1 |
--help Show this help |
1 2 3 4 5 6 7 |
-H --halt Halt the machine<br> -P --poweroff Power-off the machine<br> -r --reboot Reboot the machine<br> -h Equivalent to --poweroff, overridden by --halt<br> -k Don't halt/power-off/reboot, just send warnings<br> --no-wall Don't send wall message before halt/power-off/reboot<br> -c Cancel a pending shutdown |

命令示例
1、立即关闭计算机
1 |
robin@robin-Lenovo:~$ shutdown -h now #now 立刻time=0 |
2、在5分钟后关机,并提示关机警示信息
1 |
robin@robin-Lenovo:~$ shutdown -h +5 "system will shutdown afte 5 minutes"<br> Shutdown scheduled for Thu 2018-12-27 23:32:37 CST, use 'shutdown -c' to cancel. |
3、在21:00关机,并提示关机警示信息
1 |
robin@robin-Lenovo:~$ shutdown -h 21:00 "system will shutdown at 21:00"<br> Shutdown scheduled for Fri 2018-12-28 21:00:00 CST, use 'shutdown -c' to cancel. |
4、在22:00重启系统,并提示关机警示信息
1 |
robin@robin-Lenovo:~$ shutdown -r 22:00 "system will reboot at 22:00"<br> Shutdown scheduled for Fri 2018-12-28 22:00:00 CST, use 'shutdown -c' to cancel. |