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

Linux命令之shutdown的更多相关文章

  1. 64个命令,每天一个linux命令目录, shutdown,tee,rcp,

    每天一个linux命令目录 开始详细系统的学习linux常用命令,坚持每天一个命令,所以这个系列为每天一个linux命令.学习的主要参考资料为: 1.<鸟哥的linux私房菜> 2.htt ...

  2. 理解Linux中的shutdown、poweroff、halt和reboot命令

    原文  http://os.51cto.com/art/201706/541525.htm   在本篇中,我们会向你解释 shutdown.poweroff.halt 以及 reboot 命令.我们会 ...

  3. 每天一个Linux命令(64)shutdown命令

        shutdown以一种安全的方式关闭系统.     (1)用法:     用法:  shutdown [参数] [时间]     (2)功能:     功能:  系统关机命令,shutdown ...

  4. Linux命令——shutdown、halt、poweroff、reboot、cal、date

    shutdown shutdown在关机的时候会通知所有用户 shutdown –r now 现在重启 shutdown now 现在关机 shutdown +5 过5分钟关机 shutdown –c ...

  5. 每天一条linux命令——shutdown

    shutdown命令用来系统关机命令.shutdown指令可以关闭所有程序,并依用户的需要,进行重新开机或关机的动作. 语法: shutdown(选项)(参数) 选项: -c:当执行“shutdown ...

  6. linux常用命令:shutdown 命令

    shutdown以一种安全的方式关闭系统. 1.命令格式: shutdown [参数] [时间] 2.命令功能:     功能:  系统关机命令,shutdown指令可以关闭所有程序,并依用户的需要, ...

  7. 每天一个Linux命令(2):shutdown命令

    shutdown命令是系统关机命令.shutdown指令可以关闭所有程序,并依用户的需要,进行重新开机或关机的动作. 语法 shutdown(选项)(参数) 选项 -c:取消已经在进行的 shutdo ...

  8. Linux命令随笔

    Linux命令总结 man ==命令帮助; help ==命令的帮助(bash的内置命令); ls ==list,查看目录列表; -ld:查看目录权限; -l:(long)长格式显示属性; -F:给不 ...

  9. 第2章 新手必须掌握的Linux命令

      第2章 新手必须掌握的Linux命令 章节简述: 本章节讲述系统内核.Bash解释器的关系与作用,教给读者如何正确的执行Linux命令以及常见排错方法. 经验丰富的运维人员可以恰当的组合命令与参数 ...

随机推荐

  1. think in java 读书笔记

    第三章 操作符 3.1 更简单的打印语句  原:System.out.println("打印"); 简单:print("我是更简单的");  =======需要 ...

  2. Access denied for user 'root'@'IP' (using password:YES)解决方法

    在MySql的使用过程中,碰到“Access denied for user 'root'@'IP' (using password:YES)”的问题,使用以下语句修改后还是不行. GRANT ALL ...

  3. C语言基础:数组 分类: iOS学习 c语言基础 2015-06-10 21:40 7人阅读 评论(0) 收藏

    数组:是由一组具有相同数据类型的数据组合而来. 数组定义:元素类型修饰符 数组名[数组个数]={元素1,元素2....};  int arr[ 2 ]={1,2};    //正确 int arr[ ...

  4. 内置变量WEBGL

    gl_FragCoord是片元着色器中的只读变量,它保存了片元相对窗口的坐标位置:x, y, z, 1/w.这个值是顶点处理产生片元后固定功能内插图元的结果.组件z是用于表示片元深度的深度值. gl_ ...

  5. 2017-2018-2 20165228 实验二《Java面向对象程序设计》实验报告

    2017-2018-2 20165228 实验二<Java面向对象程序设计>实验报告 相关知识点 三种代码 伪代码:注释,与具体编程语言无关 产品代码:由伪代码翻译而来的具体编程语言语法相 ...

  6. MySQL最基本的DML语句

    一.什么叫DML? DML(Data Manipulation Language):数据操作语言.主要操作数据表中的数据,使用DML可以完成以后三件事: 插入数据 修改数据 查询数据 二.具体的语句操 ...

  7. 2019寒假算法基础集训营1 - B 小a与"204"

    题目: 小a非常喜欢这个数字,因为. 现在他有一个长度为的序列,其中只含有这三种数字 设为序列中第个数,你需要重新排列这个数列,使得最大(公式的含义是:每个数与前一个数差的平方的和) 注意:我们默认 ...

  8. linux rpm yum 安装 软件

    rpm 安装: 1.rpm包的了解:  rpm  安装  升级  删除 rpm -ivh  ****.rpm   安装 rpm -Uvh  ****.rpm  升级 rpm -e name    删除 ...

  9. C++学习(十九)(C语言部分)之 指针3

    复习1.一级指针 int*p 指向int的指针 赋值 int x; p=&x;// *p=2; 指针指向的谁 解引用之后就是谁2.内存四区 堆区 需要自己手动申请内存 自己释放 (malloc ...

  10. oracle 11g(64位)datebase 安装流程

    软件版本:oracle 11g 64位 datebase(二合一,含client) 系统环境:windows 10 专业版 64位操作系统 1)根据自己的操作系统去官网下载相应的安装程序,oracle ...