【Linux】サービス管理 ~ service ~

■ はじめに

Linuxのサービス管理(service・chkconfig)について
まとめる
なお、systemctl コマンドについては、以下の関連記事を参照。

systemd 〜 systemctlコマンド 〜
https://dk521123.hatenablog.com/entry/2025/07/01/114457

目次

【1】サービス管理
 1)CentOS6以前
 2)CentOS7以降
【2】service / chkconfigコマンド
 1)サービス起動・停止
 2)サービス自動起動
 3)サービスリストの確認

【1】サービス管理

1)CentOS6以前

* service・chkconfigコマンドを利用

2)CentOS7以降

* systemctl コマンドを利用
 => なお、systemctl コマンドについては、以下の関連記事を参照。

systemd 〜 systemctlコマンド 〜
https://dk521123.hatenablog.com/entry/2025/07/01/114457

【2】service / chkconfigコマンド

1)サービス起動・停止

[1-1] サービスの起動

# service <サービス名> start
sudo service docker start

[1-2] サービスの停止

# service <サービス名> stop
sudo service docker stop

[1-3] サービスの再起動

# service サービス名 restart
sudo service docker restart

2)サービス自動起動

[2-1] サービスの自動起動設定

# chkconfig サービス名 on
sudo chkconfig docker on

[2-2] サービスの自動起動解除

chkconfig サービス名 off
sudo chkconfig docker off

3)サービスリストの確認

sudo service --status-all

https://dk521123.hatenablog.com/entry/2020/05/24/000000

でトラブルシュートした際に

http://var.blog.jp/archives/85880603.html

で知った。
サービスリストに登録されているかどうかが分かり
トラブルシュート時に役に立つ。

参考文献

http://www.server-memo.net/centos-settings/centos7/service-start.html
http://www.server-memo.net/centos-settings/centos7/systemctl-enable.html
構文などが分かる
https://wiki.archlinuxjp.org/index.php/Systemd

関連記事

Linuxの起動 ~ プロセス / デーモン ~
https://dk521123.hatenablog.com/entry/2015/02/07/232402
systemd 〜 入門編 〜
https://dk521123.hatenablog.com/entry/2017/07/30/100204
systemd 〜 systemctlコマンド 〜
https://dk521123.hatenablog.com/entry/2025/07/01/114457
systemd 〜 journalctl 〜
https://dk521123.hatenablog.com/entry/2025/01/01/012049
Amazon ECR でのトラブルシューティング
https://dk521123.hatenablog.com/entry/2020/05/24/000000
Linux(仮想環境) を構築する ~CentOS編~
Tomcatをデーモンとして起動するには ~ /etc/init.d / Debian編~
Tomcatをデーモンとして起動するには ~ /etc/init.d / openSUSE編~
Linuxでの開発用SMTPサーバー [2] ~ MailCatcher編 ~
AWS(Amazon Web Services) ~ 入門編 / EC2作成 ~