init.dにスクリプトを追加できません。

init.dにスクリプトを追加できません。

リモートUbuntuサーバーにgerritをインストールしました。さて、サーバーの再起動時に自動的に起動したいと思います。私はこれに従おうとしています:

http://gerrit-documentation.googlecode.com/svn/Documentation/2.3/install.html#rc_d

これは2行です:

sudo ln -snf `pwd`/home/gerrit2/gerrit_application/bin/gerrit.sh /etc/init.d/gerrit.sh
sudo ln -snf ../init.d/gerrit.sh /etc/rc3.d/S90gerrit

両方のファイルが作成されたことを確認しました。しかし、アプリケーションを再起動しても起動しません。それでも手動で起動する必要があります。

root@mm11:/home/gerrit2/gerrit_application/bin# ./gerrit.sh start

この問題をどのようにデバッグ/修正できますか?

私も次のことを試しました。

sudo ln -snf /home/gerrit2/gerrit_application/bin/gerrit.sh /etc/init.d/gerrit
sudo update-rc.d gerrit defaults

これは作る:

root@mm11:/home/gerrit2# update-rc.d gerrit defaults
 Adding system startup for /etc/init.d/gerrit ...
   /etc/rc0.d/K20gerrit -> ../init.d/gerrit
   /etc/rc1.d/K20gerrit -> ../init.d/gerrit
   /etc/rc6.d/K20gerrit -> ../init.d/gerrit
   /etc/rc2.d/S20gerrit -> ../init.d/gerrit
   /etc/rc3.d/S20gerrit -> ../init.d/gerrit
   /etc/rc4.d/S20gerrit -> ../init.d/gerrit
   /etc/rc5.d/S20gerrit -> ../init.d/gerrit

ベストアンサー1

まず、スクリプトをスクリプトプールにコピーする必要があります。

/etc/init.d/

Linuxには、さまざまな実行レベルでプールへのリンクセットを含むディレクトリセットがあります。

/etc/rc0.d # for runlevel 0 for trun off system in all of dirstos
/etc/rc1.d # runlevel 1, for single user in all distros
/etc/rc2.d # runlevel 2 , default runlevel for debian-base dirstros
/etc/rc3.d # runlevel 3, in redhat-base systems, using for everything without graphical mode
/etc/rc4.d # runlevel 4,reserved by system
/etc/rc5.d  #runlevel 5 , in  Redhat base , defualt runlevel
/etc/rc6.d  # for runlevel 6 for reboot system in all of distros

以下を実行する必要があります。

ln -s /etc/init.d/YOUR_SCRIPT /etc/rcNUMBER.d/{S OR K}NUMYOUR_SCRIPT

たとえば、

ln -s /etc/init.d/apache2 /etc/rc2.d/S99apache2

S OR K : S statrt, K: Kill
NUM before script: priority of run, if you have two scrip such S10squid amd S99apache, At first squid will be run then apache. 

update-rc.d比較chkconfig:

update-rc.dDebian-baseシステム内で作業し、システムchkconfig内で作業してくださいredhat-base

おすすめ記事