Python crontab script doesnt seem to work. When i run it manually,
python /home/ec2-user/code1.py
it works fine but when put into cron.txt file for the crontab, doesnt.
My crontab file is:
@hourly python /home/ec2-user/code1.py >/dev/null 2>&1
i also tried
0 * * * * python /home/ec2-user/code1.py >/dev/null 2>&1
But neither have much luck.
sudo crontab -l
@hourly python /home/ec2-user/code1.py >/dev/null 2>&1
Shows everything functional. I tried Crontab not running my python script and couple others with not much luck either.
With
PATH=/opt/python2.7/bin
MAILTO=my@email
*/5 * * * * /home/ec2-user/code1.py
Email i get is:
/bin/sh: /home/ec2-user/code1.py : No such file or directory
Yet I can open and edit the file no problem. I tried many different thing but it comes down to this: cron doesnt see the file.
Feels like I went through entire https://askubuntu.com/questions/23009/reasons-why-crontab-does-not-work and still no luck
ps aux | grep [c]ron should show a running cron processMAILTO=<email address> to your crontab, so that you get the email/opt/python2.7/bin/python) instead of just python in the commandecho FOOBAR and verify that you get the email.ls -l /homeec2-user/code1.py ? Should that be /home/ec2-user/code1.pycrontab -e never from another platform, or by editing the file directly.crontab -l | cat -A so that we can verify all the control characters are correct.did you check the following points?
is your script executable? chmod 700 code1.py
the first line in your code should be, in most cases the python is installed at this place
#!/usr/bin/pythonafter that the crontab as follow should execute
0 * * * * /home/ec2-user/code1.py >/dev/null 2>&1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With