I have the following shell script. It checks whether the python script is running or not, and if not, it will start the python script. When I run it from command line like ./crontab.sh it works even from other places like MaskRCNN/crontab.sh. But when I put it into the crontab only the echos are working.
#!/bin/bash
out=$(ps aux | grep 'python train/train.py' | rev | cut -d ' ' -f 1| rev | wc -l)
if [ $out -eq "2" ];then
echo "2 processes" >> /tmp/testing.txt
else
echo "1 process" >> /tmp/testing.txt;
cd /hdd1/Alex/testMaskRCNN_human_bodyparts/MaskRCNN_body;
CUDA_VISIBLE_DEVICES=0 /usr/bin/python train/train.py
fi
The crontab looks like this:
* * * * * /hdd1/Alex/testMaskRCNN_human_bodyparts/MaskRCNN_body/crontab.sh
I hope there are enough details. Thank you
CUDA_VISIBLE_DEVICES=0 /usr/bin/python train/train.pyis this supposed to run the script? because if it is i think the script needs to be surrounded by backticks/tmp/testing.txtget updated with 1's?