本教程操作環(huán)境:linux7.3系統(tǒng)、Dell G3電腦。
linux關(guān)機命令shutdown可以實現(xiàn)立刻關(guān)機。
(資料圖片)
linux立刻關(guān)機的命令有:
shutdown -h now立刻關(guān)機(root用戶使用)
halt立刻關(guān)機
poweroff立刻關(guān)機
如果是通過shutdown命令設(shè)置關(guān)機的話,可以用shutdown -c命令取消重啟
linux shutdown命令介紹
Linux shutdown命令可以用來進(jìn)行關(guān)機程序,并且在關(guān)機以前傳送訊息給所有使用者正在執(zhí)行的程序,shutdown 也可以用來重開機。
使用權(quán)限:系統(tǒng)管理者。
語法
shutdown [-t seconds] [-rkhncfF] time [message]
參數(shù)說明:
-t seconds : 設(shè)定在幾秒鐘之后進(jìn)行關(guān)機程序。-k : 并不會真的關(guān)機,只是將警告訊息傳送給所有使用者。-r : 關(guān)機后重新開機。-h : 關(guān)機后停機。-n : 不采用正常程序來關(guān)機,用強迫的方式殺掉所有執(zhí)行中的程序后自行關(guān)機。-c : 取消目前已經(jīng)進(jìn)行中的關(guān)機動作。-f : 關(guān)機時,不做 fcsk 動作(檢查 Linux 檔系統(tǒng))。-F : 關(guān)機時,強迫進(jìn)行 fsck 動作。time : 設(shè)定關(guān)機的時間。message : 傳送給所有使用者的警告訊息。實例
立即關(guān)機
# shutdown -h now
指定 10 分鐘后關(guān)機
# shutdown -h 10
重新啟動計算機
# shutdown -r now
命令語法:
/sbin/shutdown [-t sec] [-arkhncfFHP] time [warning-message]
命令參數(shù):
參數(shù) | 長參數(shù) | 描敘 |
-a | Use /etc/shutdown.allow. | |
-c | 中斷關(guān)機:當(dāng)執(zhí)行"shutdown -h 12:00"指令時,只要按+鍵就可以中斷關(guān)機的指令 | |
-f | 重新啟動時不進(jìn)行磁盤檢測(fsck) | |
-F | 重新啟動時進(jìn)行磁盤檢測(fsck) | |
-h | 關(guān)閉電源 | |
-k | 模擬關(guān)機(不是真的關(guān)機),只是向登錄者發(fā)送警告信息出去! | |
-n | 不調(diào)用init進(jìn)程進(jìn)行關(guān)機,而是強行關(guān)機 | |
-r | 關(guān)閉系統(tǒng)然后重新啟動,類似于Windows平臺restart | |
-t | 延遲關(guān)機的時間 | |
-w | 僅做測試,并不真的將系統(tǒng)重新開機,只會把重開機的數(shù)據(jù)寫入/var/log目錄下的wtmp記錄文件 | |
--help | 顯示命令在線幫助 |
示例:1:馬上關(guān)閉Linux系統(tǒng),其中 now 相當(dāng)于時間為 0 的狀態(tài)示例:
# shutdown -h now
2:系統(tǒng)2分鐘后重新啟動,其中+m表示幾分鐘后關(guān)機或開機。
[root@db-server ~]# shutdown -r +2
3:設(shè)置系統(tǒng)在那個時間點關(guān)機
# shutdown -h 12:30
或后臺執(zhí)行
# shutdown -h 12:30 &
最好是使用命令&將關(guān)機命令至于后臺處理。不影響當(dāng)前其它操作。
設(shè)置多久時間后執(zhí)行shutdown命令。時間參數(shù)有hh:mm或+m兩種模式。hh:mm格式表示在幾點幾分執(zhí)行shutdown命令。例如 “shutdown 10:45”表示將在10:45執(zhí)行shutdown.+m表示m分鐘后執(zhí)行shutdown.比較特別的用法是以now表示立即執(zhí)行shutdown. 值得注意的是這部分參數(shù)不能省略。另外,需要注意如果現(xiàn)在已經(jīng)22:30,你執(zhí)行了shutdown -h 22:00 & 那么第二天才會關(guān)機。
4:查看后臺是否執(zhí)行shutdown命令
# jobs[1]+ Running shutdown -h 08:00 &
5:取消shutdown命令執(zhí)行
執(zhí)行了下面命令讓Linux在12:30關(guān)機,但是如果發(fā)現(xiàn)這個時間點不合適,那么可以使用CTRL+C取消。
# shutdown -h 12:30Shutdown cancelled.
也可以在另外一個命令窗口執(zhí)行下面命令
# shutdown -c
6:向所有登錄的用戶發(fā)出信息
# shutdown -k "now"Broadcast message from root (pts/2) (Sat Jan 10 20:09:14 2015):The system is going down to maintenance mode NOW!Shutdown cancelled.
另外登錄的會話窗口會收到如下信息
[root@db-server ~]# [root@db-server ~]#
Broadcast message from root (pts/2) (Sat Jan 10 20:11:34 2015):The system is going down to maintenance mode NOW!
一般使用下面語法,如下所示
[root@db-server ~]# shutdown -k now "The Server will shutdown now
Broadcast message from root (pts/1) (Sat Jan 10 20:14:54 2015):The Server will shutdown now The system is going down to maintenance mode NOW!Shutdown cancelled.
7:重新啟動時不進(jìn)行磁盤檢測
[root@db-server ~]# shutdown -fr nowBroadcast message from root (pts/1) (Sat Jan 10 20:23:59 2015): The system is going down for reboot NOW!
8:在多少秒后關(guān)閉系統(tǒng)并給用戶發(fā)送提示信息
[root@db-server ~]# shutdown -t 10 -h now "System will shutdown 10 sencond later" Broadcast message from root (pts/1) (Sat Jan 10 20:33:36 2015): System will shutdown 10 sencond later The system is going down for system halt NOW!
推薦學(xué)習(xí):Linux視頻教程
以上就是linux關(guān)機命令shutdown可以實現(xiàn)立刻關(guān)機嗎的詳細(xì)內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章!