Why my disk and CPU are busy without me
I'm off at the beach this weekend with the family so I brought the trusty MacBook along. Overnight I closed the lid, putting the MacBook to sleep, and not long after I opened it this morning iStat menu was showing a lot of CPU activity and I could hear the disk thrashing a bit. I wasn't running anything other than Safari at the time so I became curious; what was causing the machine to work all of a sudden?
When I looked at iStat it was showing that the find process was using 75% of my CPU activity. But what was find and why was it working now?
After a little research I found that according to Apple's site find is a file system maintenance utility and that it is run as part of a daily, weekly and monthly schedule. Since I had put the MacBook into sleep mode overnight and the daily and weekly scheduled tasks had not run OS X decided to run it not long after I took it out of sleep mode. Normally these maintenance tasks are scheduled to run at 03:15 everyday, 04:30 on Saturdays, and 05:30 on the first day of each month.
All told it ran for about 15 minutes or so with varying periods of activity. I also found that I could see what was inside these tasks by examining the results of the daily, weekly and monthly logs. If you want to see what your Mac has been up to while you were sleeping just pop open one of the following files:
/var/log/daily.out
/var/log/weekly.out
/var/log/monthly.out
Inside of these files are the details of what the scheduled maintenance tasks were up to.
Comments
I noticed in Removing old log files:
- Removing old temporary files:
- Removing scratch and junk files:
In Windows, I've seen temporary folders reach ridiculous sizes. It's great that my Mac sorts all this kind of thing out in the background. More importantly, it's great that this is sorted out for the non-tech savvie.
Also, have you noticed that many of the logs (best way to see them is by opening 'Console') are automatically archived and compressed each period? Great stuff!
I help a fair number of non-technical people get used to Macs and always have them purchase the modestly prices pref pane as it eliminates having to think about basic maintenance, performing the routines automatically.
http://www.atomicbird.com/macaroni
Now that my primary operating system (Mac) is built on top of BSD I'm finding myself with a reason to explore more and am enjoying it.
sudo mv /etc/periodic/weekly/310.locate ~/backup
Just FYI, it's "cron", not chron. cron stands form "Command Run On", which lets you run any unix command at any recurring date/time.
Steve
I found a book on Unix for Tiger that looks promising - I assume that little has changed from Tiger to Leopard on the Unix side. Any feedback there is appreciated!
After the introduction of launchd in 10.4 and 10.5, the periodic functions were no longer initiaed by cron, but by launchd. Launchd has a "calendar"-style function which exists strictly to make sure that the operative software is run at the next time after the "calendar interval". As such, it is very likely that periodic will be run at the nearest approximation of weekly on any system with Leopard (and I believe this is true for Tiger as well).
For more details, the man pages for launchd.plist and /System/Library/LaunchDaemons/*periodic* are informative.
Cheers,
-Gaige