systemctl と service どちらを使えばいい?

ショコラ
ショコラ

systemctl と service どちらを使えばいい?

systemctl を使うようにする。
systemctl には service には無い自動起動の enable、disable がある。
因みに service の自動起動の設定には chkconfigコマンドを使う。
「service ユニット名 start」 と 「systemctl start ユニット名」 は同じです。
ただ、ドッカーコンテナの中では service コマンドで動かしますね。

もっさん先輩
もっさん先輩

systemctlコマンド

サービスを開始

systemctl start {ユニット名}

サービスを停止

systemctl stop {ユニット名}

サービスをリスタート

systemctl restart {ユニット名}

サービスをリロード

systemctl reload {ユニット名}

サービスの状態を表示

systemctl status {ユニット名}

サービスの自動起動の状態を表示

systemctl is-enable {ユニット名}

サービスの自動起動

systemctl enable {ユニット名}

サービスの自動起動の解除

systemctl disable {ユニット名}

serviceコマンド

サービスを起動

service {サービス名} start

サービスを停止

service {サービス名} stop

サービスをリスタート

service {サービス名} restart

サービスをリロード

service {サービス名} reload

サービスの状態を表示

service {サービス名} status

chkconfigコマンド

service の自動起動の設定には chkconfigコマンドを使います。

サービスの自動起動

chkconfig {サービス名} on

サービスの自動起動の解除

chkconfig {サービス名} off

systemctl で nginx をリロードします。

systemctl reload nginx

systemctl で apache2 をリロードします。

systemctl reload apache2

service で nginx をリロードします。

service nginx reload

service で apache2 をリロードします。

service apache2 reload
Scroll to Top