gpt4 book ai didi

linux - 重新激活 python 脚本 - Linux bash 脚本

转载 作者:太空宇宙 更新时间:2023-11-04 12:18:44 24 4
gpt4 key购买 nike

<分区>

我不明白为什么我的“for 循环”不能正常工作。第一个参数工作正常。如果我手动停用第二个 python 脚本,它不会再次启动脚本。你能帮我一下吗?

#!/bin/bash
cd /home/admin/instaTweet

bots=( one.py two.py three.py )
botSize=${#bots[*]}
checkProcessSize=$(ps -e -o comm= | grep screen | wc -l)


echo $(date) >> checkBotsLog.txt
echo "$botSize Bots available" >> checkBotsLog.txt

if [ $botSize -gt $checkProcessSize ]
then
time=$(date)
tweet_string="###ALERT### At least one bot is inactive! "$(echo $time)
python3 tweet.py "$(echo $tweet_string)"
echo "At least one Bot is inactive" >> checkBotsLog.txt

for i in $bots; do
process=$(ps -aux | grep "python $i" | wc -l)

if [ $process -lt 2 ]
then
screen -d -m python $i
echo $i started >>checkBotsLog.txt
fi
done
else
time=$(date)
tweet_string="All bots are active! "$(echo $time)
python3 tweet.py "$(echo $tweet_string)"
echo "Everything fine" >> checkBotsLog.txt
fi

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com