Perform System Housekeeping on portable macs (See related posts)

I say on portable mac's because if you have a desktop that never gets shut off, these run automatically.

sudo periodic daily weekly monthly

Comments on this post

klktrk posts on Jan 17, 2006 at 19:19
You can create launchd items for these tasks and have them run at intervals, rather than on a calendar, so they get run just as long as you keep your mac running for the set interval.

Here's an example of my daily launch set up. As you can see, I changed it from launching at a specific time of day/week, to launching at an interval of 86400 seconds (24 hours). Launchd will automatically "catch up" on missed interval tasks.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Disabled</key>
        <true/>
        <key>Label</key>
        <string>com.apple.periodic-daily</string>
        <key>LowPriorityIO</key>
        <true/>
        <key>Nice</key>
        <integer>1</integer>
        <key>OnDemand</key>
        <false/>
        <key>Program</key>
        <string>/usr/sbin/periodic</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/sbin/periodic</string>
                <string>daily</string>
        </array>
        <key>ServiceDescription</key>
        <string>Daily maintenance tasks for the Darwin subsystem.</string>
        <key>StartInterval</key>
        <integer>86400</integer>
</dict>
</plist>

or, if you're using the XJanitor.pl script to handle the tasks, you can do something like this, and all three maintenance tasks will run as necessary.:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.TheApotek.XJanitor-PL</string>
        <key>LowPriorityIO</key>
        <true/>
        <key>Program</key>
        <string>/Users/widholmk/Library/PreferencePanes/XJanitor.prefPane/Contents/Resources/XJanitor.pl</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/sbin/XJanitor.pl</string>
        </array>
        <key>ServiceDescription</key>
        <string>Runs maintenance tasks on schedule, regardless of restarts (launchd), or crontab.</string>
        <key>StartInterval</key>
        <integer>900</integer>
</dict>
</plist>


If you're using XJanitor, remember to disable the com.apple.periodic-daily, com.apple.periodic-weekly, and com.apple.periodic-monthly by setting the disabled key to TRUE, like so:
...
<dict>
        <key>Disabled</key>
        <true/>
...etc
klktrk posts on Jan 17, 2006 at 19:20
<string>/Users/widholmk/Library/PreferencePanes/XJanitor.prefPane/Contents/Resources/XJanitor.pl</string>


should be
<string>/usr/sbin/XJanitor.pl</string>


sorry.

You need to create an account or log in to post comments to this site.


Related Posts