MacOS – How to run AppleScript in a Crontab

cronmacmacos

I am using OS X 10.11.5, I have a crontab file under '/tmp/crontab', in which it contains:

01 10 * * * /Users/Jhon/Desktop/somescript.scpt

When I run crontab -l I get output as no crontab for Jhon

Any suggestion what I am doing wrong here?

Best Answer

Apple recommends using launchd which actually runs cron tasks for MacOS. You can still use crontab -e to edit your crontab, but if you want a one-liner:

(crontab -l 2>/dev/null; echo "01 10 * * * osascript /Users/Jhon/Desktop/somescript.scpt") | crontab - ; crontab -l

See this answer for much more useful details:

How can I configure my computer to run an AppleScript at a specific time? Caveat: without using iCal