检测端口的守护进程

由于要定时检查某个程序是否一直占用某个端口,如果没有占用就重新执行该程序。这里写了个简单的shell来判断。这里以openwrt上执行gae为例:

#! /bin/sh

# feature :check tcp port 8087 alive
# author :comet
# created time :2013-08-20 16:38:00

APPPORT=`netstat -ant|grep :8087`
APPCMD="python /root/gaeclient/proxy.py &"

#echo ${APPPORT}
if [ -z "${APPPORT}" ]
then
    ${APPCMD}
fi