Home > Enterprise >  Crontab isn't running python script as intended
Crontab isn't running python script as intended

Time:09-28

On my Mac OSX, crontab is not running a script as intended. When I enter crontab -l it returns

5 15 * * 1-5 /Users/me/opt/anaconda3/bin/python /Users/me/Documents/my_text/sms_text.py

To my knowledge, this means 15:05 UTC, which is 8:05am west coast US (where I am and as desired), running only on weekdays hence the 1-5.

I've run sms_text.py locally (not scheduled) without ay issues.

Is something wrong with the crontab script/command captured above?

CodePudding user response:

You can make the following changes to fix this behaviour

  1. Add a log redirection to get information on what's happening when the cronjob is triggered

5 15 * * 1-5 python /Users/me/opt/anaconda3/bin/python /Users/me/Documents/my_text/sms_text.py > /Users/me/opt/anaconda3/bin/python /Users/me/Documents/my_text/sms_text.out 2>&1

  1. Add python/python3 in the job as well based on your environment

5 15 * * 1-5 python /Users/me/opt/anaconda3/bin/python /Users/me/Documents/my_text/sms_text.py

  • Related