[Linux] CentOSでサービスの起動・停止・状態の確認を行う方法

CentOS7では、サービスの起動などの方法が 「service start サービス名」から違う方式に変更されました。CentOS5との比較で記載します。

CentOS5でのコマンド

「httpd」を起動・停止・再起動・状態確認するには以前は以下のようにコマンドを打っていました。

# service start httpd
# service stop httpd
# service restart httpd
# service status httpd

試しにCentOS7で「」を打ってみると

The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

というメッセージが返ってきます。「systemctl」を使ってくださいというメッセージが書かれています。

CentOS7でのコマンド

「systemctl」方式に変更になりました。

# systemctl start httpd
# systemctl stop httpd
# systemctl restart httpd
# systemctl status httpd

というコマンドになります。



Author: webmaster