【Purpose】
Shell script monitor prog function
【Eevironment】
Ubuntu 16.04 bash env
【Procdeure】
Source code:
#!/bin/bash while [ 1 ] do # get under /appServer/app directory prog numbers nprogs=`ls -t /appServer/app | cut -d" " -f1 | wc -l` #echo $nprogs if [ $nprogs -eq 0 ] then echo "not progs" > /dev/null else #echo "judge driver running status" for i in `seq 1 $nprogs` do #echo $i prog=`ls -t /appServer/app | cut -d" " -f1 | head -n"$i" | tail -n1` #echo $prog ps -ef | grep "$prog" | grep -q -v grep if [ $? -ne 0 ];then #/appServer/app/$prog > /dev/null & /appServer/app/$prog & fi done fi sleep 60 done