在linux領域內大多用在服務器上,特殊情況下,不得已關機。
正確的關機流程爲:sync > shutdown > reboot > halt
關機指令爲:shutdown
,你可以man shutdown
來看一下幫助文檔。
例如:
sync 將數據由內存同步到硬盤中。
shutdown 關機指令,你可以man shutdown 來看一下幫助文檔。例如你可以運行如下命令關機:
shutdown –h 10 ‘This server will shutdown after 10 mins’ 這個命令告訴大家,計算機將在10分鐘後關機,並且會顯示在登陸用戶的當前屏幕中。
Shutdown –h now 立馬關機
Shutdown –h 20:25 系統會在今天20:25關機
Shutdown –h +10 十分鐘後關機
Shutdown –r now 系統立馬重啓
Shutdown –r +10 系統十分鐘後重啓
reboot 就是重啓,等同於 shutdown –r now
halt 關閉系統,等同於shutdown –h now 和 poweroff
總之,不管是重啓系統還是關閉系統,首先要運行 sync
命令,把內存中的數據寫到磁盤中。
關機的命令有 shutdown –h now halt poweroff
和 init 0 , 重啓系統的命令有 shutdown –r now reboot init 6
。