新聞中心
作為一名系統(tǒng)管理員,在你關閉服務器之前,你也許想要發(fā)送一條消息來警告他們系統(tǒng)將要關閉。默認上,shutdown命令會給其他系統(tǒng)用戶廣播信息。

在先前的文章中,我們解釋了 Linux 中shutdown、poweroff、halt、reboot 命令的不同之處,并揭示了在用不同的選項執(zhí)行這些命令時它們實際做了什么。
本篇將會向你展示如何在系統(tǒng)關機時向所有的系統(tǒng)用戶發(fā)送一條自定義的消息。
**建議閱讀:**tuptime – 顯示 Linux 系統(tǒng)的歷史和統(tǒng)計運行時間。
作為一名系統(tǒng)管理員,在你關閉服務器之前,你也許想要發(fā)送一條消息來警告他們系統(tǒng)將要關閉。默認上,shutdown命令會如下所示給其他系統(tǒng)用戶廣播這條信息:
# shutdown 13:25
Linux 關機操作廣播消息
Shutdown scheduled for Fri 2017-05-12 13:25:00 EAT, use 'shutdown -c' to cancel.
Broadcast message for root@tecmint (Fri 2017-05-12 13:23:34 EAT):
The system is going down for power-off at Fri 2017-05-12 13:25:00 EAT!
要在 shutdown 那行發(fā)送一條自定義的消息給其他系統(tǒng)用戶,運行下面的命令。在本例中,關閉會在命令執(zhí)行后的兩分鐘之后發(fā)生。
# shutdown 2 The system is going down for required maintenance. Please save any important work you are doing now!
假設你有一些關鍵的系統(tǒng)操作,如計劃系統(tǒng)備份或更新會在系統(tǒng)關閉的時候進行,如下所示,你可以使用 -c 選項取消關機,并在執(zhí)行玩這些操作后繼續(xù)執(zhí)行:
# shutdown -c
Linux 關機操作取消消息:
Shutdown scheduled for Fri 2017-05-12 14:10:22 EAT, use 'shutdown -c' to cancel.
Broadcast message for root@tecmint (Fri 2017-05-14 :10:27 EAT):
The system shutdown has been cancelled at Fri 2017-05-12 14:11:27 EAT!
另外,學習如何在 Linux 中使用簡單和傳統(tǒng)的方法:在重啟或者開機時自動執(zhí)行命令/腳本。
現(xiàn)在你知道了如何在系統(tǒng)關閉前向其他系統(tǒng)用戶發(fā)送自定義消息了。你有其他關于這個主題想要分享的想法么?
文章標題:Linux關機前向用戶發(fā)送自定義消息
標題路徑:http://fisionsoft.com.cn/article/cocchhe.html


咨詢
建站咨詢
