I have python program, I want to run it everyday with different variable (on CentOS server):
#!/bin/sh
/usr/bin/python /root/testing/test.py --variables /root/testing/daily/test1.txt
while [ $? != 0 ]
do
sleep 60
/usr/bin/python /root/testing/test.py --variables /root/testing/daily/test1.txt
done
sleep 60
runs, but there is no python in htop and program output is empty.
I changed python to /usr/bin/python because when I searched I found answer that it can fix.
Also before running this python code i have another little one, which just updates old files, that program runs and works very. When I'm running this shell program from terminal entering sh tester.sh it works, problem is only when running from cron.
Also it worked in Ubuntu server.
What is wrong? Can cron and shell script work different in CentOS?
Also, my crontab syntax:
22 23 * * * sh /root/testing/cron-work.sh >> /root/cron1.log
23 23 * * * sh /root/testing/cron-work2.sh >> /root/cron2.log
24 23 * * * sh /root/testing/cron-work3.sh >> /root/cron3.log
14 23 * * * sh /root/testing/cron-work4.sh >> /root/cron4.log
Answer
Nothing helped to run from path. Moved all programs to /usr/local/bin and added path for bash and for python to programs. Now I can run them just entering cron-work.sh in shell. And also in crontab writing program's name without path. Everything works fine.
No comments:
Post a Comment