zoukankan      html  css  js  c++  java
  • Linux命令之shutdown

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

    SHUTDOWN(8)                                      shutdown                                     SHUTDOWN(8)
    
    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, 5 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, 0 is returned, a non-zero failure code otherwise.
    
    SEE ALSO
           systemd(1), systemctl(1), halt(8), wall(1)
    
    systemd 229                                                                                   SHUTDOWN(8)

    从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           //在12:00关机

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

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

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

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

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

    [root@CentOS6 桌面]# shutdown –k 5 “Waring:maybe the system will be shutdown”
    [root@CentOS6 桌面]#
    Broadcast message from root@CentOS6.8(/dev/pts/0) at 14:26 …
     
    The system is going down for maintenance in 5 minutes!
    Waring:maybe the system will be shutdown
  • 相关阅读:
    js用button激活 Alert 元素关闭按钮的交互功能
    js中的$符号代表什么
    js中#代表什么
    amazeui学习笔记--js插件(UI增强)--警告框Alert
    amazeui学习笔记--css(常用组件16)--文章页Article
    amazeui学习笔记--css(常用组件15)--CSS动画Animation
    amazeui学习笔记--css(常用组件14)--缩略图Thumbnail
    amazeui学习笔记--css(常用组件13)--进度条Progress
    amazeui学习笔记--css(常用组件12)--面板Panel
    amazeui学习笔记--css(常用组件11)--分页Pagination
  • 原文地址:https://www.cnblogs.com/hwli/p/9609087.html
Copyright © 2011-2022 走看看