rcX.dフォルダに起動スクリプトと終了スクリプトがペアで表示されないのはなぜですか?

rcX.dフォルダに起動スクリプトと終了スクリプトがペアで表示されないのはなぜですか?

起動時に実行する必要があるスクリプトは、次の場所にあります。/etc/init.dそしてその中に含まれるファイル/etc/rc*.dシンボリックリンクは/etc/init.dのファイルを指します。また、シンボリックリンクの名前は、特定の実行レベルでサービスが開始されたか(S *)か停止されたか(K *)かを示します。確認するために "ls -al"コマンドを実行しました。/etc/rc3.d、出力は次のようになります。

drwxr-xr-x.  2 root root 4096 Apr  6 23:04 .
drwxr-xr-x. 10 root root 4096 May 22  2015 ..
lrwxrwxrwx.  1 root root   20 May 22  2015 K50netconsole -> ../init.d/netconsole
lrwxrwxrwx.  1 root root   17 May 22  2015 K90network -> ../init.d/network
lrwxrwxrwx.  1 root root   17 May 22  2015 S00livesys -> ../init.d/livesys
lrwxrwxrwx.  1 root root   16 Apr  6 23:04 S85mongod -> ../init.d/mongod
lrwxrwxrwx.  1 root root   15 May 31  2015 S95jexec -> ../init.d/jexec
lrwxrwxrwx.  1 root root   22 May 22  2015 S99livesys-late -> ../init.d/livesys-late

開始スクリプトと終了スクリプトがペアで出なければならないと思いましたが、これが間違っているのはなぜですか?

ベストアンサー1

RHEL6または同様のLinuxの場合、これらのスクリプトは通常adminによって管理されますchkconfig(8)。これにより、ペアではなく、各サービスの各実行レベルに対して起動スクリプトまたは停止スクリプトがあることを確認します。 (Ubuntuや他のものについてはよくわかりません)。

マニュアルページからchkconfig

Note that for every service, each runlevel has either a start script 
or a stop script.  When switching runlevels, init will not re-start an 
already-started service, and will not re-stop a  service that is not running.

...

--add name
  This option adds a new service for management by chkconfig.  When a new service is added, 
  chkconfig ensures that the service has either a start or a kill entry in  every  runlevel.  
  If  any  runlevel is missing such an entry, chkconfig creates the 
  appropriate entry as specified by the default values in the init script.

回答実行レベルに関する別の質問命名規則を説明します。

今、命名体系もかなり簡単になりました。名前がSで始まるスクリプトはその実行レベルで始まり、名前がKで始まるスクリプトは終了します。

ランレベル変更スクリプトを見ると、ランレベルが変更されるたびにそのスクリプトがパラメータとして実行され、入力されたパラメータでスクリプトが実行されている/etc/rc様子が表示されます。 KスクリプトとSスクリプトの両方があるということは、スクリプトが各実行レベルで停止して開始されることを意味します。S*startK*stop

# rc            This file is responsible for starting/stopping
#               services when the runlevel changes.
...
# First, run the KILL scripts.
for i in /etc/rc$runlevel.d/K* ; do
        ...
        $i stop
done
# Now run the START scripts.
for i in /etc/rc$runlevel.d/S* ; do
        ...
                exec $i start
        ...
done

私はRHEL6システムだけを見ているので、これが他のディストリビューションでどう違うかを確認できる人がいればそうしてください。

おすすめ記事