LoginSignup
3
1

More than 3 years have passed since last update.

デーモンってなに? init.d配下の確認

Posted at

勉強前イメージ

よく聞くけど、実はあんまりちゃんと分かってない。
serviceコマンドで起動・停止が出来る?
http"d" とか mysql"d" の "d" はデーモンのdだったような気がする...

調査

デーモンとは

UNIX系OSにおける常駐プログラムのことを指します
裏(バックグラウンド)で常に起動していて、要求があれば応答するようなものです。
起動時はRedhat系であれば/etc/rc.d/init.d配下にコントロールするファイルがある

デーモンの設定(現在はsystemdに管理されているので、あまり表示されない)

デーモンはランレベルに応じて起動したり停止したりします。
ランレベルの説明は こちら
スクリプトは /etc/init.d に置かれているのが自動起動設定されているものです(systemdに設定されているもの以外)

[root@localhost ~]# ll /etc/init.d/
合計 40
-rw-r--r--. 1 root root  1160  8月  7 02:30 README
-rw-r--r--. 1 root root 18281  8月 19  2019 functions
-rwxr-xr-x. 1 root root  4569  8月 19  2019 netconsole
-rwxr-xr-x. 1 root root  7928  8月 19  2019 network

その設定は /etc/rc?.d の配下にあります。
0-6まであります。

[root@localhost rc3.d]# ll /etc/rc*
lrwxrwxrwx.  1 root root  13  8月 31 11:26 /etc/rc.local -> rc.d/rc.local
lrwxrwxrwx.  1 root root  10  8月 31 11:26 /etc/rc0.d -> rc.d/rc0.d
lrwxrwxrwx.  1 root root  10  8月 31 11:26 /etc/rc1.d -> rc.d/rc1.d
lrwxrwxrwx.  1 root root  10  8月 31 11:26 /etc/rc2.d -> rc.d/rc2.d
lrwxrwxrwx.  1 root root  10  8月 31 11:26 /etc/rc3.d -> rc.d/rc3.d
lrwxrwxrwx.  1 root root  10  8月 31 11:26 /etc/rc4.d -> rc.d/rc4.d
lrwxrwxrwx.  1 root root  10  8月 31 11:26 /etc/rc5.d -> rc.d/rc5.d
lrwxrwxrwx.  1 root root  10  8月 31 11:26 /etc/rc6.d -> rc.d/rc6.d

実際に /etc/rc3.d を見てみると....

[root@localhost ~]# ll /etc/rc3.d/
合計 0
lrwxrwxrwx. 1 root root 20  8月 28 16:46 K50netconsole -> ../init.d/netconsole
lrwxrwxrwx. 1 root root 17  8月 28 16:46 S10network -> ../init.d/network

S10networkK50netconsole があります。

[S/K][数字][スクリプト名] という順番で、

  • [S/K]

S : 起動する(start)
K : 停止する(kill)

  • [数字]

優先度を表し、数字が小さいほど優先度が高く先に実行されます。
上記の例で行くと、 S10networkK50netconsole の順番です。

  • [スクリプト名]

apacheなどサービスの名称が入ってきます。

勉強後イメージ

今回は短いけど、結構面白かった。
ほぼsystemdに移行しちゃってたからあんまり見えなかったけど...
数日前に出した、ランレベルとの話もあったし点と点が線になった気がする
mysqldもsshdもすべてデーモンで、バックグラウンドでずっと待機しててくれる子。

参考

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1