shell 等待某个进程的加载

有时候一些进程是需要依赖另外一个进程的服务的。

#!/bin/bash

waite(){
	if [ $# -eq 1 ]
	then
	    while(true);do
		sleep 1s 
		    pid=`ps -ef | grep "$1" | grep -v grep | awk '{print $2}'`
			if [ "$pid" != "" ]
			then
				break
			fi
	    done
	else
	    echo "The input parameter must be 1"
	fi
}

echo "begin wait for process startup"
# 执行wait方法,查询是否有myapp.py的进程存在 waite myapp.py echo "process started"

 

 
posted @ 2021-11-09 10:20  蜜铀  阅读(154)  评论(0编辑  收藏  举报