最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux系統(tǒng)下的重啟,關(guān)機命令以及reboot掛死問題解決方案

 更新時間:2024年11月29日 15:00:15   作者:零時搞學(xué)習  
本文介紹了Linux系統(tǒng)中關(guān)機和重啟的命令及其作用,以及系統(tǒng)運行等級的差別,此外,還分享了一個解決reboot關(guān)機卡死問題的方法

Linux開關(guān)機

在Linux下,我們常用 shutdown、reboot、poweroff、halt等進行關(guān)機或重啟

另外還有就是直接使用 init 修改循行等級進行,如:init 0、init 6等

各命令的作用:

reboot 重啟

可接參數(shù)如下:

Reboot the system.

     --help      Show this help
     --halt      Halt the machine
  -p --poweroff  Switch off the machine   
     --reboot    Reboot the machine
  -f --force     Force immediate halt/power-off/reboot  
  -w --wtmp-only Don't halt/power-off/reboot, just write wtmp record
  -d --no-wtmp   Don't write wtmp record
     --no-wall   Don't send wall message before halt/power-off/reboot

這里主要講一下`reboot -f`,強制重啟

在使用`reboot`這個命令過程中,有在CentOS8.2系統(tǒng)中遇到reboot掛死,約等待

30mins才能關(guān)機然后重新啟動,后來修改命令為`reboot -f`之后,問題解決

關(guān)機流程:

  • 1.通知所有運行中的進程:系統(tǒng)將發(fā)送SIGTERM信號給所有正在運行的進程,通知它們系統(tǒng)即將關(guān)機。
  • 2.停止所有運行中的進程:系統(tǒng)會逐個終止所有正在運行的進程,直到?jīng)]有剩余進程為止。
  • 3.關(guān)閉所有打開的文件:系統(tǒng)會關(guān)閉所有打開的文件,確保所有數(shù)據(jù)都被正確地寫入到磁盤中。
  • 4.停止所有設(shè)備:系統(tǒng)會停止所有設(shè)備的運行,包括磁盤、網(wǎng)絡(luò)設(shè)備和其他硬件設(shè)備。
  • 5.關(guān)閉內(nèi)核:系統(tǒng)會釋放內(nèi)核占用的所有資源,并退出內(nèi)核運行狀態(tài)。
  • 6.重啟計算機:系統(tǒng)會發(fā)送一個重啟指令給計算機,計算機將重新啟動,并加載操作系統(tǒng)。

相似的reboot命令:

system reboot
shutdown -r now
init 6

shutdown 關(guān)機

[root@localhost ~]# shutdown --help
shutdown [OPTIONS...] [TIME] [WALL...]

Shut down the system.

     --help      Show this help
  -H --halt      Halt the machine
  -P --poweroff  Power-off the machine
  -r --reboot    Reboot the machine
  -h             Equivalent to --poweroff, overridden by --halt
  -k             Don't halt/power-off/reboot, just send warnings
     --no-wall   Don't send wall message before halt/power-off/reboot
  -c             Cancel a pending shutdown

poweroff 用于關(guān)閉計算機

halt 用于關(guān)閉計算機或進入停機狀態(tài),有些系統(tǒng)是調(diào)用shutdown -h 或poweroff

再深入了解一下系統(tǒng)運行等級的差別:

首先明確一下linux/redhat系的runlevel運行級別和debian系的runlevel是有所不同的。

redhat系的runlevel定義如下:

  • runlevel 0: halt 系統(tǒng)停機狀態(tài),系統(tǒng)默認運行級別不能設(shè)為0,否則不能正常啟動
  • runlevel 1: single user 單用戶工作狀態(tài),root權(quán)限,用于系統(tǒng)維護,禁止遠程登陸
  • runlevel 2: multiuser without network 多用戶狀態(tài)(沒有NFS)
  • runlevel 3: multiuser 完全的多用戶狀態(tài)(有NFS),登陸后進入控制臺命令行模式
  • runlevel 4: unuse 系統(tǒng)未使用,保留
  • runlevel 5: x11 X11控制臺,登陸后進入圖形GUI模式
  • runlevel 6: reboot 系統(tǒng)正常關(guān)閉并重啟,默認運行級別不能設(shè)為6,否則不能正常啟動

在debian/ubuntu中,runlevel的定義為:

0 - Halt
1 - Single
2 - Full multi-user with display manager (GUI)
3 - Full multi-user with display manager (GUI)
4 - Full multi-user with display manager (GUI)
5 - Full multi-user with display manager (GUI)
6 - Reboot

可以發(fā)現(xiàn)2~5級是沒有任何區(qū)別的。

Ubuntu系統(tǒng)默認的運行級別為2。

因此,我們可以使用init 0來執(zhí)行halt關(guān)機,使用init 6來執(zhí)行reboot。

其實shutdown命令也是在執(zhí)行完一系列操作后,比如說逐個關(guān)閉進程/服務(wù),調(diào)用sync將數(shù)據(jù)寫入磁盤等,然后調(diào)用init0或init6來執(zhí)行關(guān)機或重啟而halt實際上是調(diào)用shutdown -h now,可以不理會系統(tǒng)當前狀態(tài)而直接關(guān)機,但在有的系統(tǒng)中,halt不會關(guān)閉電源,而只關(guān)閉了os。

問題描述

reboot 發(fā)生掛死,reboot關(guān)機時卡了近半個小時,才能關(guān)機下去,重啟上電流程無異常。

環(huán)境:

CentOS Stream release 8
Linux 4.18.0-500.el8.x86_64
systemd 239 (239-76.el8)

問題解決嘗試

首先當然從系統(tǒng)入手,我查詢了/var/log/messages上面記錄的內(nèi)容,發(fā)現(xiàn)沒什么錯誤信息

先沒有計較太多,我直接使用yum update更新了一下我的系統(tǒng),再次嘗試

1,百度尋醫(yī)問藥,修改/etc/systemd/system.conf ,修改系統(tǒng)參數(shù),但是并未有改善,此方案不適用我這邊的狀況

2,嘗試其他的reboot方案,都會發(fā)生掛死,命令如下:

system reboot
shutdown -r now
init 6

3,最后嘗試使用reboot -f,此時系統(tǒng)reboot 正常,并未發(fā)現(xiàn)重啟掛死的狀況

20230914 解決了reboot關(guān)機卡死狀況,解決辦法如下:

1、新建/etc/systemd/system/rc-local.service并寫入

	[Unit]
	Description=/etc/rc.d/rc.local Compatibility
	ConditionFileIsExecutable=/etc/rc.d/rc.local
	After=network.target
	[Service]
	Type=forking
	ExecStart=/etc/rc.d/rc.local start
	TimeoutSec=5
	RemainAfterExit=yes

2、備份/etc/systemd/system.conf

cp -a /etc/systemd/system.conf /etc/systemd/system.conf_bak

3、修改文件

sed -i 's/#DefaultTimeoutStopSec=90s/DefaultTimeoutStopSec=30s/g' /etc/systemd/system.conf

4、重新加載

systemctl daemon-reload

這幾種命令區(qū)別在哪里呢

目前僅僅知道 reboot -f 會 強制重新開機,不調(diào)用shutdown指令的功能,看起來跟普通的重啟動作是不同的,或許會發(fā)生數(shù)據(jù)丟失的狀況,從描述來看,少做了很多動作。

reboot命令OS的動作:

1、結(jié)束所有運行中的進程:系統(tǒng)會發(fā)送SIGTERM信號給所有正在運行的進程,通知它們系統(tǒng)即將重啟。

2、保存當前系統(tǒng)狀態(tài):系統(tǒng)會將當前系統(tǒng)的狀態(tài)保存到/var/log/wtmp文件中,包括系統(tǒng)的運行時間、用戶登錄信息等。

3、停止所有設(shè)備:系統(tǒng)會停止所有設(shè)備的運行,包括磁盤、網(wǎng)絡(luò)設(shè)備和其他硬件設(shè)備。

4、重啟計算機:系統(tǒng)會發(fā)送一個重啟指令給計算機,計算機將重新啟動,并加載操作系統(tǒng)

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

沽源县| 枣庄市| 镇赉县| 洪湖市| 阿坝| 务川| 阳原县| 青铜峡市| 和政县| 阿尔山市| 海晏县| 胶州市| 且末县| 遂溪县| 海淀区| 大埔区| 岢岚县| 淅川县| 思茅市| 贵溪市| 宣武区| 政和县| 洪湖市| 连平县| 尉犁县| 合肥市| 长葛市| 九台市| 偏关县| 长沙市| 鄂尔多斯市| 肇源县| 平陆县| 科尔| 澳门| 金塔县| 满城县| 宁都县| 犍为县| 揭阳市| 科尔|