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