如果我做一个:
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?或者需要一个正常的启动脚本格式?
答案1
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