在 Linux 服务器关机前向用户显示一条自定义消息
![](http://static.careerengine.us/api/aov2/http%3A_%7C__%7C_mmbiz.qpic.cn_%7C_mmbiz_jpg_%7C_eQYGxygoIBiciaOIwr6hVxQFDL3Px0NzMUvBQ7hrUt64JOQNf2ibFUpK3CsRgTRv54H2szib8wYA5F56X2sTXKeevQ_%7C_0%3Fwx_fmt%3Djpeg.jpg)
![](http://static.careerengine.us/api/aov2/http%3A_%7C__%7C_mmbiz.qpic.cn_%7C_mmbiz_jpg_%7C_eQYGxygoIBiciaOIwr6hVxQFDL3Px0NzMUvBQ7hrUt64JOQNf2ibFUpK3CsRgTRv54H2szib8wYA5F56X2sTXKeevQ_%7C_0%3Fwx_fmt%3Djpeg.jpg)
在先前的文章中,我们解释了 Linux 中 shutdown、poweroff、halt、reboot 命令的不同之处[1],并揭示了在用不同的选项执行这些命令时它们实际做了什么。
本篇将会向你展示如何在系统关机时向所有的系统用户发送一条自定义的消息。
作为一名系统管理员,在你关闭服务器之前,你也许想要发送一条消息来警告他们系统将要关闭。默认上,
shutdown
命令会如下所示给其他系统用户广播这条信息:#shutdown13:25
Linux 关机操作广播消息
Shutdown scheduled forFri2017-05-1213:25:00 EAT,use'shutdown -c' to cancel.
Broadcast message for root@tecmint (Fri2017-05-1213:23:34 EAT):
The system is going down for power-off at Fri2017-05-1213:25:00 EAT!
要在 shutdown 那行发送一条自定义的消息给其他系统用户,运行下面的命令。在本例中,关闭会在命令执行后的两分钟之后发生。
#shutdown2The system is going down for required maintenance.Please save any important work you are doing now!
![](http://static.careerengine.us/api/aov2/http%3A_%7C__%7C_mmbiz.qpic.cn_%7C_mmbiz_png_%7C_eQYGxygoIBiciaOIwr6hVxQFDL3Px0NzMUBcPcpuNhL8RA7QYJj9PHP9ia7gkQiaNVB8usuQBxiaBEPUMiaDpHD5AgQg_%7C_0%3Fwx_fmt%3Dpng.jpg)
Linux 系统关闭消息
假设你有一些关键的系统操作,如计划系统备份或更新会在系统关闭的时候进行,如下所示,你可以使用
-c
选项取消关机,并在执行玩这些操作后继续执行:#shutdown-c
Linux 关机操作取消消息:
Shutdown scheduled forFri2017-05-1214:10:22 EAT,use'shutdown -c' to cancel.
Broadcast message for root@tecmint (Fri2017-05-14:10:27 EAT):
The system shutdown has been cancelled at Fri2017-05-1214:11:27 EAT!
另外,学习如何在 Linux 中使用简单和传统的方法在重启或者开机时自动执行命令/脚本[3]。
不要错过:
现在你知道了如何在系统关闭前向其他系统用户发送自定义消息了。你有其他关于这个主题想要分享的想法么?何不使用下面的评论栏?
作者简介:
Aaron Kili 是一个 Linux 和 F.O.S.S 爱好者、Linux 系统管理员、网络开发人员,现在也是 TecMint 的内容创作者,他喜欢和电脑一起工作,坚信共享知识。
推荐文章
< 左右滑动查看相关文章 >
输入文章 ID 或长按二维码直达
最新评论
推荐文章
作者最新文章
你可能感兴趣的文章
Copyright Disclaimer: The copyright of contents (including texts, images, videos and audios) posted above belong to the User who shared or the third-party website which the User shared from. If you found your copyright have been infringed, please send a DMCA takedown notice to [email protected]. For more detail of the source, please click on the button "Read Original Post" below. For other communications, please send to [email protected].
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。