欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PHP脚本监控程序

程序员文章站 2022-03-13 14:01:04
#!/bin/sh # find ip ip=`/sbin/ifconfig eth1 | grep 'inet addr' | awk '{ print substr(...
#!/bin/sh


# find ip
ip=`/sbin/ifconfig eth1 | grep 'inet addr' | awk '{ print substr($2, index($2, ":")+1)}'`


#monitor procname scriptname
monitor()
{
	procname=$1
	scriptname=$2
	# find proc by procname
	rc=$(ps -ef | grep $procname | grep -v grep | wc -l)
	if [ $rc -eq 0 ]; then
		echo "$procname start"
		php $scriptname &
	else
		echo "$procname running"
	fi
	sleep 1
}


#monitor proc
monitor "beanstalkd_service" "/home/www/phpxiu/public/beanstalkd_service.php"