the below bash script is set to kill firefox processes (used by python script) and kill any running same script before running the python script in a loop untill it give error code 0.
#!/bin/bash
for pid in $(pidof -x start-manheim.sh);
do
if [ $pid != $$ ]; then
kill -9 $pid;
fi
done
while true
do
#pkill -f firefox;
echo "starting script on `date`";
python3 mmr-gen.py;
if [ $? -eq 0 ]
then
break;
fi
done
The script run manually perfectly as it is supposed to, but when using cron :
*/2 * * * * /bin/bash /root/start-manheim.sh >> /root/manheim.log
the script just loops through it without running any python. log data:
starting script on Sat Jul 9 14:54:01 UTC 2022
starting script on Sat Jul 9 14:54:02 UTC 2022
starting script on Sat Jul 9 14:54:03 UTC 2022
starting script on Sat Jul 9 14:54:04 UTC 2022
starting script on Sat Jul 9 14:54:05 UTC 2022
starting script on Sat Jul 9 14:54:06 UTC 2022
starting script on Sat Jul 9 14:54:08 UTC 2022
starting script on Sat Jul 9 14:54:09 UTC 2022
starting script on Sat Jul 9 14:54:10 UTC 2022
starting script on Sat Jul 9 14:54:11 UTC 2022
starting script on Sat Jul 9 14:54:12 UTC 2022
starting script on Sat Jul 9 14:54:13 UTC 2022
starting script on Sat Jul 9 14:54:14 UTC 2022
starting script on Sat Jul 9 14:54:15 UTC 2022
starting script on Sat Jul 9 14:54:17 UTC 2022
starting script on Sat Jul 9 14:54:18 UTC 2022
starting script on Sat Jul 9 14:54:19 UTC 2022
starting script on Sat Jul 9 14:54:20 UTC 2022
starting script on Sat Jul 9 14:54:21 UTC 2022
starting script on Sat Jul 9 14:54:22 UTC 2022
starting script on Sat Jul 9 14:54:23 UTC 2022
starting script on Sat Jul 9 14:54:24 UTC 2022
starting script on Sat Jul 9 14:54:25 UTC 2022
starting script on Sat Jul 9 14:54:26 UTC 2022
starting script on Sat Jul 9 14:54:27 UTC 2022
starting script on Sat Jul 9 14:54:28 UTC 2022
starting script on Sat Jul 9 14:54:29 UTC 2022
starting script on Sat Jul 9 14:54:30 UTC 2022
starting script on Sat Jul 9 14:54:31 UTC 2022
starting script on Sat Jul 9 14:54:32 UTC 2022
starting script on Sat Jul 9 14:54:34 UTC 2022
starting script on Sat Jul 9 14:54:35 UTC 2022