Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
853 views
in Technique[技术] by (71.8m points)

macos - Crontab not executing a Python script on my Mac?

I can run this in my terminal /Users/quintus/opt/anaconda3/bin/python /Users/quintus/Desktop/python/04_Jobs/Jobs.py

However, I can not set up my crontab, I type 48 23 * * * /Users/quintus/opt/anaconda3/bin/python /Users/quintus/Desktop/python/04_Jobs/Jobs.py

I read similar questions but haven't found solution.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have not worked on my Mac in a while, but I just logged in to test this. If you try the following it might work:

48 23 * * * python3 /Users/quintus/Desktop/python/04_Jobs/Jobs.py

That would get the script to run in Python 3.x and if you want to use Python 2.x just replace python3 with python. I migh t have done something extra to get python3 command to work, but if that is the case it was much too long ago.

Also, this will run every 48 hours and 23 min. I just want to point that out because it seems very odd timing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...