-1

I have been trying to run a python script on my MAC every day automatically with no success so far. I failed using launched, and I am now trying to use crontab to see if I am luckier that way.

The script runs OK without using crontab:

cd '/Users/johnEd/Documents/code/myFolder' && '/usr/local/bin/python3' 'myfile.py'

I have been able to install a new crontab

20 10 * * * cd '/Users/johnEd/Documents/code/myFolder' && '/usr/local/bin/python3' 'myfile.py'

The crontab lists when I do crontab -l but it does not seem to run at all

bad_coder
  • 11,289
  • 20
  • 44
  • 72
WewillSee
  • 279
  • 3
  • 13
  • Are you on the same user in the console both times? Are you sure it doesn't run and not just error when running? -> Add output redirection to a file, set it to 5 minutes from now, see if the file is created and with what contents – h4z3 Feb 15 '22 at 10:24
  • Remember that cron uses different PATH than your normal user environment. Examining stdout and stderr outputs from your cron line should help. But you can also add `echo $PATH > /tmp/cronpath.txt` to cron and just see the PATH for yourself – h4z3 Feb 15 '22 at 10:28
  • How do you determine that it doesn't run? Please [edit] to provide debugging details. Perhaps see also [Cron job not running](https://stackoverflow.com/questions/22743548/cronjob-not-running) for general troubleshooting tips, and https://stackoverflow.com/questions/63755352/cronjobs-on-osx-catalina-not-executing for some Mac-specific guidance. (Also, what's with the wacky quoting?) – tripleee Feb 15 '22 at 10:59

1 Answers1

0

I copied the whole folder onto /opt and the file is now being executed by crontab

Thanks for your help everybody!

WewillSee
  • 279
  • 3
  • 13