CentOS7 にてサービスの起動、停止、再起動、確認、自動起動

sudo systemctl まとめ

備忘録

ログや状態など確認

$ sudo systemctl status xxxxx.service

起動

$ sudo systemctl start xxxxx.service

停止

$ sudo systemctl stop xxxxx.service

再起動

$ sudo systemctl restart xxxxx.service

自動起動

サーバーを再起動などした場合に自動で立ち上がるようにする。

# 自動起動 on
$ sudo systemctl enable xxxxx.service

# 自動起動 off
$ sudo systemctl disable xxxxx.service

# enable になっているか確認する
$ sudo systemctl is-enabled xxxxx.service

# 自動起動の on, off をリストで確認する
$ sudo systemctl list-unit-files -t service