2,163
社区成员




### 测试S100及以上是否被调用2次的代码
cat << "EOF" | tee /etc/init.d/testctrl
#!/bin/sh
#@(#)recover.script 8.7 (Berkeley) 8/16/94
#Script to test S100 called twice
case "$1" in
start)
echo `date`" starting"
;;
stop)
echo `date`" stopping"
;;
esac
exit 0
EOF
chmod 755 /etc/init.d/testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S100testctrl
### 测试S100及以上是否被调用2次的代码
cat << "EOF" | tee /etc/init.d/testctrl
#!/bin/sh
#Script to test S100 and above called twice
case "$1" in
start)
echo `date +%Y-%m-%d_%H:%M:%S.%N` "$0 starting"
;;
stop)
echo `date +%Y-%m-%d_%H:%M:%S.%N` "$0 stopping"
sleep 0.01
;;
esac
exit 0
EOF
chmod 755 /etc/init.d/testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S100testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S101testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S102testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S117testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S128testctrl
ln -s /etc/init.d/testctrl /etc/rc6.d/K100oraclectrl
ln -s /etc/init.d/testctrl /etc/rc6.d/K101oraclectrl
ln -s /etc/init.d/testctrl /etc/rc6.d/K102oraclectrl
ln -s /etc/init.d/testctrl /etc/rc6.d/K117oraclectrl
ln -s /etc/init.d/testctrl /etc/rc6.d/K118oraclectrl
经过试验,S100以上的数字都会被调用2次的
调用过程是S100、S101、S102, S100、S101、S102
用host+p的方式暂停,可以看到启动顺序是
/etc/rc2.d/S100testctrl
/etc/rc2.d/S101testctrl
/etc/rc2.d/S102testctrl
/etc/rc2.d/S100testctrl
/etc/rc2.d/S101testctrl
/etc/rc2.d/S102testctrl
starting enhanced syslogd:rsyslogd
/etc/rc2.d/S117testctrl
/etc/rc2.d/S128testctrl
/etc/rc2.d/S128testctrl
starting ACPI services
关闭的时候也是最开始
/etc/rc6.d/S100testctrl
/etc/rc6.d/S101testctrl
/etc/rc6.d/S102testctrl
/etc/rc6.d/S117testctrl
/etc/rc6.d/S118testctrl
/etc/rc6.d/S117testctrl
/etc/rc6.d/S118testctrl
stoping …… anacon
cat << "EOF" | tee /etc/init.d/testctrl
#!/bin/sh
#Script to test S100 and above called twice
case "$1" in
start)
echo `date +%Y-%m-%d_%H:%M:%S.%N` "$0 starting"
;;
stop)
echo `date +%Y-%m-%d_%H:%M:%S.%N` "$0 stopping"
sleep 0.01
;;
esac
exit 0
EOF
chmod 755 /etc/init.d/testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S100testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S101testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S102testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S117testctrl
ln -s /etc/init.d/testctrl /etc/rc2.d/S128testctrl