Ubuntu > サービスの自動起動の設定(chkconfig)

更新日 2011-12-18
広告
chkconfigコマンドを使って、サービスが自動的に起動するように設定する方法を紹介します。
Ubuntuでは、デフォルトでupdate-rc.dコマンドが用意されていますが、個人的にchkconfigコマンドに慣れちゃっているので、chkconfigを使ってみます (sysv-rc-confを使う方法はこちら)。
まずchkconfigコマンドをインストールする必要があります。
~$ sudo apt-get install chkconfig
これでインストールは完了です。
この前インストールしたpostgresqlが自動起動する設定になっているので、「自動起動しない」ように設定してみます。
~$ sudo chkconfig postgresql off
色々と warning が表示されます。 ざっと見る限り、特に問題なさそうです。
insserv: warning: script 'K20acpi-support' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'network-manager' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `network-manager'
  :
postgresqlの起動設定を確認します。
~$ sudo chkconfig postgresql --list
postgresql                0:off  1:off  2:off  3:off  4:off  5:off  6:off
全てのランレベルで off になっています。 これで、postgresqlは自動起動しません。
逆に、自動起動させたい場合は、以下のようにします。
$ sudo chkconfig postgresql on
$ sudo chkconfig postgresql --list
postgresql                0:off  1:off  2:on   3:on   4:on   5:on   6:off
インストールされているサービスは、以下のように確認できます。
$ chkconfig --list
acpi-support              0:off  1:off  2:on   3:on   4:on   5:on   6:off
acpid                     0:off  1:off  2:off  3:off  4:off  5:off  6:off
alsa-mixer-save           0:off  1:off  2:off  3:off  4:off  5:off  6:off
anacron                   0:off  1:off  2:off  3:off  4:off  5:off  6:off
apparmor                  0:off  1:off  2:off  3:off  4:off  5:off  6:off  S:on 
apport                    0:off  1:off  2:off  3:off  4:off  5:off  6:off
atd                       0:off  1:off  2:off  3:off  4:off  5:off  6:off
   :
ちなみに、ランレベルは runlevel コマンドで確認できます。
$ runlevel 
N 2
広告
お問い合わせは sweng.tips@gmail.com まで。
inserted by FC2 system