LoginSignup
5
6

More than 5 years have passed since last update.

Linuxでサービス自動起動の設定(覚え書き)

Last updated at Posted at 2016-10-26

自動起動を設定できるサービスを確認する

サービスを起動するrcスクリプト(シェルスクリプト)が収められている。

コマンド
$ cd /etc/init.d
$ ls
mysqld redis nginx ....

サービス自動起動の設定をする

今回設定するのは、mysqld・redis・nginx。

コマンド
$ sudo chkconfig mysqld on
$ sudo chkconfig redis on
$ sudo chkconfig nginx on

サービス自動起動が設定されていることを確認する

各ランレベルに対応したディレクトリが用意されている。
ランレベル
/etc/init.d内のrcスクリプト(シェルスクリプト)へのシンボリックリンクを作って利用する。
※上記コマンドを実行すると、シンボリックリンクが作成される。
※Sxx(rcスクリプト名)のように先頭にSが付いているものが実行され、xxは実行される順番。

コマンド
$ cd /etc/
$ rc5.d
$ ls
lrwxrwxrwx 1 root root 16 10 26 09:42 S64mysqld -> ../init.d/mysqld
lrwxrwxrwx 1 root root 18  9 23 10:01 S80sendmail -> ../init.d/sendmail
lrwxrwxrwx 1 root root 15 10 26 09:42 S85nginx -> ../init.d/nginx
5
6
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
5
6