> ## Content Index
> Fetch the complete content index at: https://note.xdq.me/llms.txt
> Use this file to discover other available public pages before exploring further.

# sysvinit确保一个服务晚于另一个启动
- URL: https://note.xdq.me/sysvinitque-bao-ge-fu-wu-wan-yu-ling-ge-qi-dong/
- Published: 2014-11-07T00:04:49.000Z
- Updated: 2026-10-03T02:47:12.000Z
- Author: xud6
- Tags: linux, #Import 2026-10-03 02:45

在启动脚本中加入

```
# wait until mysql started
MYSQL_OK=0
WHILE_CNT=0
while [ "$WHILE_CNT" -le 60 ] ; do
        if [[ `service mysql status` == *running* ]];     then
          MYSQL_OK=1;
          break;
        fi
        WHILE_CNT=`expr $WHILE_CNT + 1`;
   sleep 1
done

```

其中

```
`service mysql status` == *running* 

```

可以改为任何条件