linux關(guān)機(jī)命令shutdown可以實(shí)現(xiàn)立刻關(guān)機(jī),只需要root用戶執(zhí)行“shutdown -h now”命令即可。shutdown命令可以用來進(jìn)行關(guān)機(jī)程序,并且在關(guān)機(jī)以前傳送訊息給所有使用者正在執(zhí)行的程序,shutdown命令需要系統(tǒng)管理者root用戶來使用。
本教程操作環(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用戶使用)
halt
立刻關(guān)機(jī)
poweroff
立刻關(guān)機(jī)
如果是通過shutdown
命令設(shè)置關(guān)機(jī)的話,可以用shutdown -c
命令取消重啟
linux shutdown命令介紹
Linux shutdown命令可以用來進(jìn)行關(guān)機(jī)程序,并且在關(guān)機(jī)以前傳送訊息給所有使用者正在執(zhí)行的程序,shutdown 也可以用來重開機(jī)。
使用權(quán)限:系統(tǒng)管理者。
語法
shutdown [-t seconds]?[-rkhncfF]?time [message]
參數(shù)說明:
實(shí)例
立即關(guān)機(jī)
# shutdown -h now
指定 10 分鐘后關(guān)機(jī)
# shutdown -h 10
重新啟動(dòng)計(jì)算機(jī)
# shutdown -r now
命令語法:
/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)行磁盤檢測(cè)(fsck) |
-F |
? |
重新啟動(dòng)時(shí)進(jì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),類似于Windows平臺(tái)restart |
-t |
? |
延遲關(guān)機(jī)的時(shí)間 |
-w |
? |
僅做測(cè)試,并不真的將系統(tǒng)重新開機(jī),只會(huì)把重開機(jī)的數(shù)據(jù)寫入/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ī)或開機(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:30 Shutdown cancelled.
也可以在另外一個(gè)命令窗口執(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.
另外登錄的會(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!
一般使用下面語法,如下所示
[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)行磁盤檢測(cè)
[root@db-server ~]# shutdown -fr now Broadcast 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)機(jī)命令shutdown可以實(shí)現(xiàn)立刻關(guān)機(jī)嗎的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!
每個(gè)人都需要一臺(tái)速度更快、更穩(wěn)定的 PC。隨著時(shí)間的推移,垃圾文件、舊注冊(cè)表數(shù)據(jù)和不必要的后臺(tái)進(jìn)程會(huì)占用資源并降低性能。幸運(yùn)的是,許多工具可以讓 Windows 保持平穩(wěn)運(yùn)行。
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)