Init

如果不是正常形式,S99 什麼時候推出?

  • March 9, 2018

如果我這樣做:

echo "foobar" > /etc/init.d/foobar
chmod 744 /etc/init.d/foobar
ln -s /etc/init.d/foobar /etc/rc.d/rc3.d/S99foobar

在 SLES 11 上,“foobar”命令何時會在啟動期間啟動?作為最後的S99?還是需要一個正常的啟動腳本格式?

SysVinit 啟動/停止腳本根據預設“C”(又名 POSIX)語言環境的排序順序以字母數字順序S99foobar啟動,因此將在任何S99[a-e]*腳本之後但在任何S99[g-z]*腳本之前啟動。

腳本由/etc/init.d/rc主腳本啟動。相關程式碼本質上是:

for link in /etc/rc.d/rc3.d/S[0-9][0-9]*; do
   test -x "$link" || continue

   # omitted optimization: if previous runlevel already started this service, don't start it again
   # omitted logic: if $DO_CONFIRM is set, prompt for each service
   # omitted logging

   $link start; status=$?

   # omitted status reporting/logging logic based on value of $status
done

引用自:https://unix.stackexchange.com/questions/429284