0

I have a simple backup script setup as shown below. I would like to modify so that it only runs when on AC power. Is this something I can achieve with launchd settings, or perhaps I could have the backup binary check if I am on AC power and reschedule for a later run?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.myco.backups</string>

        <!-- Run this thing -->
        <key>Program</key>
        <string>/Users/hamiltont/.bin/backup.sh</string>

        <!-- Only run when there is a GUI -->
        <key>LimitLoadToSessionType</key>
        <string>Aqua</string>

        <!-- Once every 24 hours -->
        <key>StartInterval</key>
        <integer>86400</integer>

        <!-- Enable debugging -->
        <key>StandardErrorPath</key>
        <string>/tmp/com.myco.backup.err.log</string>
        <key>StandardOutPath</key>
        <string>/tmp/com.myco.backup.out.log</string>

        <!-- Play nice -->
        <key>Nice</key>
        <integer>0</integer>
</dict>
</plist>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.