Python with crontab on Mac OS X 10.5.1 Leopard

I had a simple goal: run a python script every 15 minutes throughout the day. I read up on cron and expected to move on to the next task in no time…

Four frustrating hours later, I nailed it down:

For those of you Googling for a solution, here it is:

crontab -e:


Some pointers:

1) Use the full path to the Python interpreter.

2) Make sure the path is to the correct Python interpreter.

Some of the third party modules my script imported weren’t loading because my script was looking in the wrong place.

For example, one of my earlier attempts I tried using:


But that interpreter wasn’t the same as the one I normally get when I simply type “python” at the terminal. The correct one for me is located at:


3) When referencing files from the Python script, use the full path.


text = open(‘hn_source.html’, ‘r’).read()


text = open(‘/Users/Matt/Programming/python/tests/hn_source.html’, ‘r’).read()

Bottom line: When using cron, ensure that you explicitly declare where everything is located.

3 thoughts on “Python with crontab on Mac OS X 10.5.1 Leopard

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s