linux下一個啓動和監測多個進程的shell腳本程序

#!/bin/sh
# Author:tang
# Date:2017-09-01web

ProcessName=webcrawler
InstanceCount=6
RuntimeLog='runtime.log'進程

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./libit

ulimit -c unlimiteddate

echo -n `date +'%Y-%m-%d %H:%M:%S'`
echo "----Current directory is " $PWD

# 檢查$ProcessName實例是否已經存在
while [ 1 ] ; do
#$PROCESS_NUM獲取指定進程名的數目
PROCESS_NUM=`ps -ef | grep "$ProcessName" | grep -v "grep" | wc -l`
if [ $PROCESS_NUM -lt $InstanceCount ];
then
StopCount=`expr $InstanceCount - $PROCESS_NUM `
echo -n `date +'%Y-%m-%d %H:%M:%S'`
echo "----$ProcessName service [total $StopCount] was not started."
echo -n `date +'%Y-%m-%d %H:%M:%S'`
echo "----Starting $ProcessName service[total $StopCount] ."service

for(( i = 0 ; i< $StopCount ; i++ ))
do
nohup $PWD/$ProcessName >>/dev/null 2>&1 &
done
figrep

sleep 2im

donetop

相關文章
相關標籤/搜索