Warm tip: This article is reproduced from serverfault.com, please click

How do I restore my Python cron jobs after my Mac OS upgrade?

发布于 2020-11-30 17:28:01

I recently upgraded to Mac Big Sur and have noticed my Python 3.8 cron jobs have stopped working. Under my own account in a bash shell, I can run this without issues ...

davea$ cd /Users/davea/Documents/workspace/article_project; source ./venv/bin/activate; python3 manage.py check_duplicates 

In my crontab, I had this set up, which used to work before the upgrade ...

*/5 * * * * /bin/bash -l -c 'cd /Users/davea/Documents/workspace/article_project; source ./venv/bin/activate; python manage.py check_duplicates >> /Users/davea/logs/record2.txt 2>&1'

However, after the upgrade, I'm noticing my command is never run and I see this issue in my log file

/Library/Frameworks/Python.framework/Versions/3.8/bin/python3: can't open file 'manage.py': [Errno 1] Operation not permitted

These are the permissions/groups on my "manage.py" file ...

davea$ ls -al manage.py 
-rwxrwxr-x 1 davea staff 866 Apr 15  2019 manage.py

What else do I need to do to get my cron job to run again?

Questioner
Dave
Viewed
0
Dave 2020-12-11 03:18:35

Turns out with the new Mac OS there is an extra level of permissions that need to be enabled. In System Preferences, under Security and Privacy, I clicked the Privacy tab, and then added "cron" to the "Full disk Access" list

enter image description here

then the cron jobs ran without the permissions error.