I set up a cron job for writing every minute from a python script an entry into a log file which is created from the python script. The python script is working fine if I execute it manually but it gets not executed automatically from running the cron job.

Python script:

import logging
import os

dir_path = os.path.dirname(os.path.realpath(__file__))
filename = os.path.join(dir_path, 'test_log.log')

# Logger
logger = logging.getLogger(__name__)

file_handler = logging.FileHandler(filename)
file_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))

def do_logging():

if __name__ == '__main__':

I added Terminal and cron to full disc access. The cron job was successfully created I am able to list the cron job with crontab -l. What could be the reason?

Cron view:

enter image description here

Full disk access:enter image description here

  • Is it using python2 or python3?
    – nohillside
    Apr 20, 2022 at 13:54

1 Answer 1


I logged my output of the cron job as following:

* * * * * python /Users/maxhager/test/some.py > /Users/maxhager/test/backup.log 2>&1

> /Users/maxhager/test/backup.log 2>&1 is creating a file called backup.log and logs standard output and errors.

From this information I saw that my python was not found so I changed python to python3 and it worked.


* * * * * python3 /Users/maxhager/test/some.py > /Users/maxhager/test/backup.log 2>&1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .