みーのぺーじ

みーが趣味でやっているPCやソフトウェアについて.Python, Javascript, Processing, Unityなど.

Ubuntu Serverの電源管理コマンド

昔はshutdownコマンドなどあれこれ存在して違いがあったらしいですが,現在はsystemdを使用して管理を行うようです.

systemctl(1) - Linux manual page

systemctl command Description
systemctl halt Shut down and halt the system.
systemctl poweroff Shut down and power-off the system.
systemctl reboot Shut down and reboot the system.
systemctl suspend Suspends the system.
systemctl hibernate Hibernates the system.

haltとpoweroffの違い

systemdを使用するならば必ずシャットダウン処理が実行されるため,ほとんど同じです.haltは電源を切らずにシステムを停止し,poweroffは電源を切るという意味ですが,この違いが問題となる場面はかなり少ないようです.

What is the difference between Halt and Shutdown commands? - Unix & Linux Stack Exchange

suspendとhibernateの違い

suspendはメモリーのデータをそのままに,システムを低電力状態に移行します.hibernateはメモリーのデータをハードディスクなど電源がなくてもデータが保持されるデバイスに移動してからシステムを低電力状態に移行します.suspend中に電源喪失した場合はメモリーのデータが消えるので,復帰しない場合がありますが,hibernateはそういった心配がありません.ただし,メモリーのデータ量が多い場合はそれだけのIOが発生するので時間がかかる場合があります.

What is the difference between Hibernate and Suspend - Ask Ubuntu

まとめ

日常的にはsystemctl poweroffsystemctl rebootsystemctl hibernateを使用するのがよさそうです.