Skip to content

Instantly share code, notes, and snippets.

@santocyber
Last active May 16, 2018 22:11
Show Gist options
  • Save santocyber/82b05deccfcec51de8a03311589526dd to your computer and use it in GitHub Desktop.
Save santocyber/82b05deccfcec51de8a03311589526dd to your computer and use it in GitHub Desktop.
Vericia processo PID online
#!/bin/sh
# Verificacao se servico esta online
#by SantoCyber
logfile="/home/santo/logfile"
pasta="/home/santo/InstaPy"
bot1="quickstart-frutashugreen.py"
bot2="quickstart-kinbakuestudio.py"
bot3="quickstart-growhugreen.py"
bot4="quickstart-vidaliberta.py"
bot5="quickstart-casalbitcoin.py"
bot6="quickstart-gugagautama.py"
bot7="quickstart-newmelife.py"
bot8="quickstart-shibarimorgana.py"
bot9="quickstart-shanta.py"
bot10=
while :; do
qtde1=$(ps aux | grep $bot1 | wc -l)
sleep 5
qtde2=$(ps aux | grep $bot2 | wc -l)
sleep 5
qtde3=$(ps aux | grep $bot3 | wc -l)
sleep 5
qtde4=$(ps aux | grep $bot4 | wc -l)
sleep 5
qtde5=$(ps aux | grep $bot5 | wc -l)
sleep 5
qtde6=$(ps aux | grep $bot6 | wc -l)
sleep 5
qtde7=$(ps aux | grep $bot7 | wc -l)
sleep 5
qtde8=$(ps aux | grep $bot8 | wc -l)
sleep 5
qtde9=$(ps aux | grep $bot9 | wc -l)
sleep 5
if test "$qtde1" = "1"
then
echo $bot1 "is offline";
echo "Starting...";
ps aux | grep -i $bot1 | awk '{print $2}' | xargs sudo kill -9
nohup python $pasta/$bot1 >> $logfile 2>&1 &
else
echo $bot1 "is online." ;
echo "Nada pra fazer.";
fi
sleep 30
if test "$qtde2" = "1"
then
echo $bot2 "is offline";
echo "Starting...";
ps aux | grep -i $bot2 | awk '{print $2}' | xargs sudo kill -9
nohup python $pasta/$bot2 >> $logfile 2>&1 &
else
echo $bot2 "is online." ;
echo "Nada pra fazer.";
fi
sleep 30
if test "$qtde3" = "1"
then
echo $bot3 "is offline";
echo "Starting...";
ps aux | grep -i $bot3 | awk '{print $2}' | xargs sudo kill -9
nohup python $pasta/$bot3 >> $logfile 2>&1 &
else
echo $bot3 "is online." ;
echo "Nada pra fazer.";
fi
sleep 30
if test "$qtde4" = "1"
then
echo $bot4 "is offline";
echo "Starting...";
ps aux | grep -i $bot4 | awk '{print $2}' | xargs sudo kill -9
nohup python $pasta/$bot4 >> $logfile 2>&1 &
else
echo $bot4 "is online." ;
echo "Nada pra fazer.";
fi
sleep 30
if test "$qtde5" = "1"
then
echo $bot5 "is offline";
echo "Starting...";
ps aux | grep -i $bot5 | awk '{print $2}' | xargs sudo kill -9
nohup python $pasta/$bot5 >> $logfile 2>&1 &
else
echo $bot5 "is online." ;
echo "Nada pra fazer.";
fi
sleep 30
if test "$qtde6" = "1"
then
echo $bot6 "is offline";
echo "Starting...";
ps aux | grep -i $bot6 | awk '{print $2}' | xargs sudo kill -9
nohup python $pasta/$bot6 >> $logfile 2>&1 &
else
echo $bot6 "is online." ;
echo "Nada pra fazer.";
fi
sleep 30
if test "$qtde7" = "1"
then
echo $bot7 "is offline";
echo "Starting...";
ps aux | grep -i $bot7 | awk '{print $2}' | xargs sudo kill -9
nohup python $pasta/$bot7 >> $logfile 2>&1 &
else
echo $bot7 "is online." ;
echo "Nada pra fazer.";
fi
sleep 30
if test "$qtde8" = "1"
then
echo $bot8 "is offline";
echo "Starting...";
ps aux | grep -i $bot8 | awk '{print $2}' | xargs sudo kill -9
nohup python $pasta/$bot8 >> $logfile 2>&1 &
else
echo $bot8 "is online." ;
echo "Nada pra fazer.";
fi
sleep 30
if test "$qtde9" = "1"
then
echo $bot9 "is offline";
echo "Starting...";
ps aux | grep -i $bot9 | awk '{print $2}' | xargs sudo kill -9
nohup python $pasta/$bot9 >> $logfile 2>&1 &
else
echo $bot9 "is online." ;
echo "Nada pra fazer.";
fi
sleep 30
echo "Fim.Dormindo..." ;
sleep 10
echo "." ;
sleep 10
echo ".." ;
sleep 10
echo "..." ;
sleep 10
echo "...." ;
sleep 10
echo "......" ;
sleep 10
echo "........" ;
sleep 1800
echo "Script HUGREEN VERIFICA RESTART" ;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment