Joe's Quest

Scheduled job under Mac OS X

In OS X, use crontab to run a scheduled job via shell script. Open Terminal, input 
sudo crontab -e
to enter vi editor mode to edit jobs for root user. Then use
* * * * * kill myprocess
to do some job (Here I killed myprocess) "*" means "first-last" The 5 "*" can be replaced with numbers to indicate scheduled time. 1st *: Minute (0~59) 2nd *: Hour (0~23) 3rd *: Day (1~31) Should be a valid day in the month specified below 4th *: Month (1~12) 5th *: DayOfWeek (0~7) Other parameters:
# List all jobs of user Joe
crontab -l -u Joe
# Delete all jobs
crontab -r
# Edit jobs
crontab -e
Use sudo when modify jobs for user root. Check out full manual of crontab.

Leave a Comment

Your email address will not be published. Required fields are bold.