Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'are there only unix administrators here ?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
are there only unix administrators here ?
Authored by: newbish on Jun 02, '03 11:12:48AM
"And anybody who knows the Terminal also knows about cron etc."


Actually, this is not true. A lot of the people on MacOSXHints are here to learn the UNIX-layer of Mac OS X. Certainly, I am one of them. Fortunately, there are also lots of propellar-heads who are on MacOSXHints to teach us and to share what they know. :)

That being said, cron is not the first thing most people hear about during the learning process. A lot of newbies stumble across cron early on and their reaction is, "WOW! I can make my computer do stuff at certain times without having to run another program? COOL!" But what to actually do with it is another mystery. Imagine how silly I felt thinking that the at command was another cron-like command, only to discover that an entry needed to be made in the crontab to make at work.

With all that being said, once you learn about cron and how it works, it is not difficult to edit the crontab to change the times when the janitorial routines actually run. I changed mine to the middle of the day, because that's when my computer is actually powered-on. Here's my actual crontab:

    #minute hour mday month wday who command
    #
    #*/5 * * * * root /usr/libexec/atrun
    #
    # Run daily/weekly/monthly jobs.
    15 12 * * * root periodic daily
    30 13 * * 5 root periodic weekly
    30 14 1 * * root periodic monthly


To change it, I used sudo pico /etc/crontab and changed the times. All the times in the crontab are written in 24hr format. As it reads above, my daily runs at 12:15 PM each day, the weekly runs at 1:30 PM every Friday (5), and the monthly will run at 2:30 PM on the first of the month. This maximizes the odds that periodic will run while my computer is on. The key weakness, though, is the monthly task, which may not run if the 1st falls on a weekend, and I didn't run my computer because I was out doing other things.

If I'm not sure the monthly ran, I can use:

    cat /var/log/system.log | grep "periodic monthly"

to see if it did. Of course, if the daily ran, then I will need to go to the archived log to do the same thing. If you aren't sure that a periodic ran, then you can use the periodic command to force the issue:

    sudo periodic [daily, weekly, or, monthly]
Good luck!

[ Reply to This | # ]
Nice hint...
Authored by: englabenny on Jun 02, '03 01:38:14PM
...to tell me to search and see if those jobs ever ran. I came out with a clever trick to search all of my logs, even the gzipped ones, with this line:

( cat /var/log/system.log ; gzip -dc /var/log/system.log.* ) | grep daily

And I found that the dailies and weeklies ran as proper scheduled, the daily had rum for example almost every third day..

The monthly job had however never run the last three months... I'll run it now.

[ Reply to This | # ]