开发者

check if script is running 10 times, if not restart

开发者 https://www.devze.com 2023-03-05 23:55 出处:网络
Hey, i have some problems with bash.. want to check if the ROBSTER process is running R开发者_开发知识库UNNING times if not start until;

Hey, i have some problems with bash..

want to check if the ROBSTER process is running R开发者_开发知识库UNNING times if not start until;

#!/bin/sh
SERVICE='ROBSTER'
RUNNING=20

var=$(ps aux | grep $SERVICE|grep -v SCREEN|wc -l)
echo $var

if [ $var -gt $RUNNING ]
then
for  i in $(seq $var RUNNING)
do
echo "start" 
done
fi

but it wont work :-/ :D hope you could help me


ps aux | grep ROBSTER|grep -v SCREEN

after u have changed the question:

var=$(ps aux | grep ROBSTER|grep -v SCREEN|wc -l)

echo $var 
if [ var -gt 10 ]
then 
    do run your process the number of times you need
fi
0

精彩评论

暂无评论...
验证码 换一张
取 消