Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
  1. I bought a book on OS X and it says that launchd now control the scheduling of cron tasks, it this true?
  2. Also it says that if I place commands in /etc/daily.local that they will execute after the scripts in /etc/periodic/daily.

    In my /etc/daily.local script, I just have a simple touch command (which just creates a file) so I can test to see if it works.

    I manually ran

    sudo /usr/sbin/periodic daily 
    

    to force it to execute. The file was never created.

  3. Where did I got wrong, or misunderstand anything? How should I be scheduling cron jobs in OSX Lion? Why did my book tell me to do it this way?

I'm starting to think periodic is different from cron. What is /usr/sbin/periodic?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

The files under /etc/periodic are indeed a different system than cron and crontabs. I don't advise messing with it. Use a root crontab entry instead. Run sudo crontab -e and add these lines:

MAILTO=me@foo.com
0 0 * * * sh /path/to/your/script

The first line tells cron to mail any output from the script to me@foo.com; change me@foo.com to your email address.

The second line tells cron to run your script every day at midnight.

share|improve this answer
    
If I run crontab -e under my login will it run the script as me (vs. running at root with sudo)? Does it run the script as root with sudo? Also in what file does it add this line to? –  rubixibuc Feb 18 '12 at 4:49
1  
Yes, using crontab -e without sudo will create a personal crontab, and the jobs defined in it will run as you. Using sudo crontab -e creates a root crontab, and anything in it gets run as root (not with sudo, but the result is the same). The actual crontab files are created as /usr/lib/cron/tabs/<username>. –  Gordon Davisson Feb 18 '12 at 6:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.