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


Click here to return to the 'pmset, @AppleNotOnBattery, cron' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
pmset, @AppleNotOnBattery, cron
Authored by: moritzh on May 17, '05 10:45:45PM

Very intersting info about pmset indeed. Just a quick side note regarding running cron jobs only when your Mac is connected to the power supply which can be useful for 10.3 and 10.4 users alike:

In the crontab file, you specify when you want to run your cron jobs. E.g., you could have something like this

0 22 * * * root /bin/foo.sh
to run /bin/foo.sh as root at 10 pm. By changing it to
0 22 * * * root @AppleNotOnBattery /bin/foo.sh
you will get the same, except this time /bin/foo.sh is only executed when the computer is not running on battery. Obviously, this is an Apple-specific extension and does not work on other UNIX flavors. Type man 5 crontab and man cron to learn more.

Note that this should work both in 10.3 and 10.4. I know that the way cron jobs are executed has changed from 10.3 to 10.4, but from what I understand the functionality in 10.4 should not be adversely affected. I haven't tested, though...

Also, as a general note, keep in mind that cron jobs are executed at fxed times. Usually the jobs are scheduled at times such as midnight or 3 in the morning, and since not everyone is running their computer at these times, the chances of actually running them decrease a lot, especially for users of portable computers (basically the only ones for whom the setting @AppleNotOnBattery really makes sense...). This problem is addressed by tools such as anacron or XJanitor.pl - do some google searching on these, and there also some good hints on this site on this topic, but I am too lazy to find them now, gotta do it yourself if you are interested...

Since @AppleNotOnBattery only works for cron jobs and not other custom mechanisms to launch your scripts, using the results obtained from the pmset command presented in the original hint (on 10.4) is certainly the more universal choice.



[ Reply to This | # ]