[Systemd][自分用メモ] systemctlコマンドでも電源操作が可能だと知った。

AIX、UNIX、Linux
https://archlinuxjp.kusakata.com/wiki/Systemd#.E9.9B.BB.E6.BA.90.E7.AE.A1.E7.90.86

Linuxでシャットダウンや再起動をするときは以下の様なコマンドを使用すると思いますが、systemdになってからsystemctlでも行えるようになっているのを知りました。

従来だと、

再起動:

shutdown -r now
reboot

シャットダウン:

shutdown -h now
halt

が、

systemctlだと

(再起動)systemctl reboot
(シャットダウン&パワーオフ)systemctl poweroff
(サスペンド)systemctl suspend
(ハイバネーション)systemctl hibernate
(ハイブリッドスリープ)systemctl hybrid-sleep

と別の形のものが用意されるようになりました。

他にもrescueやemergencyモードへの切り替えも行えるようになってもいるみたいです。

Systemdの採用が増えてきている以上は、こういうのも覚えておく必要がありそうです。

default
Enter default mode. This is mostly equivalent to isolate default.target.

rescue
Enter rescue mode. This is mostly equivalent to isolate rescue.target, but also prints a wall
message to all users.

emergency
Enter emergency mode. This is mostly equivalent to isolate emergency.target, but also prints a
wall message to all users.

halt
Shut down and halt the system. This is mostly equivalent to start halt.target --irreversible,
but also prints a wall message to all users. If combined with --force, shutdown of all running
services is skipped, however all processes are killed and all file systems are unmounted or
mounted read-only, immediately followed by the system halt. If --force is specified twice, the
operation is immediately executed without terminating any processes or unmounting any file
systems. This may result in data loss.

poweroff
Shut down and power-off the system. This is mostly equivalent to start poweroff.target
--irreversible, but also prints a wall message to all users. If combined with --force, shutdown
of all running services is skipped, however all processes are killed and all file systems are
unmounted or mounted read-only, immediately followed by the powering off. If --force is
specified twice, the operation is immediately executed without terminating any processes or
unmounting any file systems. This may result in data loss.

reboot [arg]
Shut down and reboot the system. This is mostly equivalent to start reboot.target
--irreversible, but also prints a wall message to all users. If combined with --force, shutdown
of all running services is skipped, however all processes are killed and all file systems are
unmounted or mounted read-only, immediately followed by the reboot. If --force is specified
twice, the operation is immediately executed without terminating any processes or unmounting
any file systems. This may result in data loss.

If the optional argument arg is given, it will be passed as the optional argument to the
reboot(2) system call. The value is architecture and firmware specific. As an example,
"recovery" might be used to trigger system recovery, and "fota" might be used to trigger a
“firmware over the air” update.


suspend
Suspend the system. This will trigger activation of the special suspend.target target.

hibernate
Hibernate the system. This will trigger activation of the special hibernate.target target.

hybrid-sleep
Hibernate and suspend the system. This will trigger activation of the special
hybrid-sleep.target target.
この記事を書いた人

kometchtech

うつ病を患いながら、IT業界の末席にいるおっさんエンジニア。科学計算をしたことがないのに、HPC分野にお邪魔している。興味のある分野で学習したことをblogにまとめつつ、うつ病の経過症状のメモも置いておく日々。じつはRouterboard User Group JPの中の人でもある。 Amazon欲しいものリスト / Arm板を恵んでくれる人募集中

kometchtechをフォローする
タイトルとURLをコピーしました