與關機、重新啟動相關的命令
?* 將數據同步寫入硬盤中的命令? sync
?* 慣用的關機命令? shutdown
?* 重新啟動、關機? reboot halt poweroff
?sync 強制將內存中的數據寫入到硬盤當中。因為linux系統中,數據會緩存在內存當中,所以為了保證數據完整保存在硬盤中,通常會在關機前使用sync命令,強制將內存中的數據寫入到緩存中。但是一般情況下,我們使用shutdown ,halt命令時,系統會自動調用 sync 命令,將緩存寫入硬盤后再關機。
?shutdown 根據目前已啟動的服務逐次關閉各項服務后才關機;
?halt? 可以在不理會系統的情況下,進行硬件關機;
?
NAME
?????? shutdown - Halt, power-off or reboot the machine
SYNOPSIS
?????? shutdown [OPTIONS...] [TIME] [WALL...]
?????? shutdown 參數?? 時間字段? 通知(wall message 也可以叫大字報)
DESCRIPTION
?????? shutdown may be used to halt, power-off or reboot the machine.
?????? shutdown 用于關閉、重啟服務器
?????? The first argument may be a time string (which is usually "now"). Optionally, this may be followed by a wall message to
?????? be sent to all logged-in users before going down.
?????? 第一個參數可以是一個關于時間的字段(通常是 now).通常,后面會跟一個消息,這個消息會在執行命令前被發送給每一個使用者。
?????? The time string may either be in the format "hh:mm" for hour/minutes specifying the time to execute the shutdown at,
?????? specified in 24h clock format. Alternatively it may be in the syntax "+m" referring to the specified number of minutes m
?????? from now.? "now" is an alias for "+0", i.e. for triggering an immediate shutdown. If no time argument is specified, "+1"
?????? is implied.時間字段 time string 也可以是格式化的時間 (hh:mm),表示在多長時間之后關閉服務器,時間使用24h制。+m 表示從現在開始幾分鐘之后關閉服務器。'now'表示時間是0,立即觸發shutdown.如果沒有指明參數,默認在一分鐘之后關閉服務器。
?????? Note that to specify a wall message you must specify a time argument, too.
?????? 記得指明時間參數的時候也指明(wall message) 標語。
?????? If the time argument is used, 5 minutes before the system goes down the /run/nologin file is created to ensure that
?????? further logins shall not be allowed.
?????? 時間參數被確定之后,系統在服務器關閉前五分鐘內不在允許用戶登錄。
OPTIONS
?????? The following options are understood:
?????? --help
?????????? Print a short help text and exit.
?????? -H, --halt
?????????? Halt the machine. 關閉服務器
?????? -P, --poweroff
?????????? Power-off the machine (the default).
?????? -r, --reboot
?????????? Reboot the machine.
?????? -h
?????????? Equivalent to --poweroff, unless --halt is specified. 等價于
?????? -k
?????????? Do not halt, power-off, reboot, just write wall message. 僅僅寫wall message,不用關閉、重啟服務器。
?????? --no-wall
?????????? Do not send wall message before halt, power-off, reboot. 關閉、重啟服務器之前不發送wall message
?????? -c
?????????? Cancel a pending shutdown. This may be used cancel the effect of an invocation of shutdown with a time argument that
?????????? is not "+0" or "now". 取消關閉服務器 通常之前執行的關機命令,它的時間參數不是 +0 或 ‘now’
EXIT STATUS
?????? On success, 0 is returned, a non-zero failure code otherwise.
SEE ALSO
?????? systemd(1), systemctl(1), halt(8), wall(1)
systemd 219
?
halt 關機但不關閉電源
halt -p 關機并且關閉電源
運行等級的切換
?* run level 0 : 關機
?* run level 3 : 純文本模式
?* run level 5 : 含有圖形接口模式
?* run level 6 : 重新啟動
使用 init 0 也可以關機