shutdown命令安全地将系统关机。 有些用户会使用直接断掉电源的方式来关闭linux,这是十分危险的。因为linux与windows不同,其后台运行着许多进程,所以强制关机可能会导致进程的数据丢失﹐使系统处于不稳定的状态﹐甚至在有的系统中会损坏硬件设备。可用man shutdown来了解命令的详细使用。

SHUTDOWN()                                      shutdown                                     SHUTDOWN()

NAME
shutdown - Halt, power-off or reboot the machine SYNOPSIS
shutdown [OPTIONS...] [TIME] [WALL...] DESCRIPTION
shutdown may be used to halt, power-off or reboot the machine. The first argument may be a time string (which is usually "now"). Optionally, this may be followed
by a wall message to be sent to all logged-in users before going down. The time string may either be in the format "hh:mm" for hour/minutes specifying the time to
execute the shutdown at, specified in 24h clock format. Alternatively it may be in the syntax "+m"
referring to the specified number of minutes m from now. "now" is an alias for "+0", i.e. for
triggering an immediate shutdown. If no time argument is specified, "+1" is implied. Note that to specify a wall message you must specify a time argument, too. If the time argument is used, minutes before the system goes down the /run/nologin file is
created to ensure that further logins shall not be allowed. OPTIONS
The following options are understood: --help
Print a short help text and exit. -H, --halt
Halt the machine. -P, --poweroff
Power-off the machine (the default). -r, --reboot
Reboot the machine. -h
Equivalent to --poweroff, unless --halt is specified. -k
Do not halt, power-off, reboot, just write wall message. --no-wall
Do not send wall message before halt, power-off, reboot. -c
Cancel a pending shutdown. This may be used cancel the effect of an invocation of shutdown
with a time argument that is not "+0" or "now". EXIT STATUS
On success, is returned, a non-zero failure code otherwise. SEE ALSO
systemd(), systemctl(), halt(), wall() systemd SHUTDOWN()

从man page可知道:shutdown被用来暂停、关闭、重启机器。shutdown后面有3个参数,都是有[],说明都是可选参数。在DESCRIPTION里了解到,如果未指定TIME参数,那就意味着默认配置“+1”,单位为分钟。如果TIME参数为now,那就意味着时间配置为“+0”,单位为分钟。时间也可设置为"hh:mm" = hour/minutes进行操作。

命令参数说明:

--help:帮助
-H/--half:关闭机器
-P/--poweroff:关闭机器
-r/--reboot:重启机器
-h:与--poweroff一样
-k:不暂停、不关闭、不重启机器,只发送消息给在线的用户
--no-wall:暂停、关闭、重启机器前,不发送消息给在线的用户
-c:取消shutdown命令操作

实例:

特定时间执行关机命令

shutdown –h now             //立即关机
shutdown –h : //在12:00关机

指定五分钟后关机,并发出警告信息

shutdown + “This System will be shutdown in  minutes”
Broadcast message from root@CentOS6.(/dev/pts/) at : … The system is going down for maintenance in minutes! //系统提醒
This System will be shutdown in minutes //用户自定义提醒

指定3分钟后重启,并发出警告信息

shutdown –r + “3分钟后关机重启”
Broadcast message from root@CentOS6.(/dev/pts/) at : … The system is going down for reboot in minutes! //系统提醒
3分钟后关机重启 //用户自定义提醒

给所有登录用户发送提醒,不关闭重启。

[root@CentOS6 桌面]# shutdown –k  “Waring:maybe the system will be shutdown”
[root@CentOS6 桌面]#
Broadcast message from root@CentOS6.(/dev/pts/) at : … The system is going down for maintenance in minutes!
Waring:maybe the system will be shutdown

最新文章

  1. AssetsManagerEx 组件使用说明
  2. Windows上安装Maven
  3. [CoreOS 转载] CoreOS实践指南(四):集群的指挥所Fleet
  4. 常用的sql函数
  5. Static、final、abstract、接口、构造方法及java语法总结
  6. PHP服务器负载判断
  7. spark storage之SparkEnv
  8. Ubuntu 12.04如何从登录界面登录root
  9. Everything You Wanted to Know About Machine Learning
  10. JSONArray用法jquery循环list<Map>对象
  11. [USACO 12JAN]Mountain Climbing
  12. Jetty 开发指南: 嵌入式开发之HelloWorld
  13. eclipse配置逆向工程
  14. [NOI2002] 贪吃的九头龙
  15. note 4 三大结构
  16. XtraBackup的备份原理与应用示例
  17. python文件处理指针的移动
  18. java 对象数组
  19. C# 队列(Queue) 和堆栈(Stack)
  20. 爬虫 (6)- Scrapy 实战案例 - 爬取不锈钢的相关钢卷信息

热门文章

  1. RIP路由协议(一)
  2. DS18B20读数错误排除
  3. 【计算机视觉】KCF算法
  4. 九度OJ1020-最小正方形-判大小
  5. 高斯消元 o(n^3) 取摸和不取摸
  6. 《DSP using MATLAB》Problem 6.23
  7. @EnableConfigurationProperties、@EnableAsync、 @EnableTransactionManagement
  8. web网页【2】
  9. <jsp:include>动作元素,附:最易出错的一点
  10. HttpClient-传入url得到json字符串( PostMethod method = new PostMethod(url)是个好方法)