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>Disabledkey>
        />
        <key>Labelkey>
        com.apple.periodic-daily</string>
        <key>LowPriorityIOkey>
        />
        <key>Nicekey>
        1</integer>
        <key>OnDemandkey>
        />
        <key>Programkey>
        /usr/sbin/periodicstring>
        ProgramArguments</key>
        <array>
                <string>/usr/sbin/periodicstring>
                daily</string>
        array>
        ServiceDescription</key>
        <string>Daily maintenance tasks for the Darwin subsystem.string>
        StartInterval</key>
        <integer>86400integer>
</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>Labelkey>
        com.TheApotek.XJanitor-PL</string>
        <key>LowPriorityIOkey>
        />
        <key>Programkey>
        /Users/widholmk/Library/PreferencePanes/XJanitor.prefPane/Contents/Resources/XJanitor.plstring>
        ProgramArguments</key>
        <array>
                <string>/usr/sbin/XJanitor.plstring>
        </array>
        <key>ServiceDescriptionkey>
        Runs maintenance tasks on schedule, regardless of restarts (launchd), or crontab.</string>
        <key>StartIntervalkey>
        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>Disabledkey>
        />
...etc
klktrk posts on Jan 17, 2006 at 19:20
<string>/Users/widholmk/Library/PreferencePanes/XJanitor.prefPane/Contents/Resources/XJanitor.plstring>


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


sorry.

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


Related Posts