Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've tried this plist file in both /Library/LaunchAgents and /Library/LaunchDaemons but neither seem to work. I can run the shell script it's supposed to call from the command line and it works fine. I edited the plist to run at a time two or three minutes from the current time and it runs fine, but when I leave it to run at night (computer on, admin user/me logged in or not) it never runs and nothing ever shows up in the log. Script is owned by me and permissions are 755, plist is owned by root and permissions are 744. System is running OS X 10.8.x. Thanks.

<?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>local.Daily.Backup.plist</string>
    <key>OnDemand</key>
    <true/>
    <key>RunAtLoad</key>
    <false/>
    <key>Program</key>
    <string>/Users/hansgruber/backup/dailyBackup.sh</string>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Weekday</key>
        <integer>1</integer>
        <key>Hour</key>
        <integer>20</integer>
        <key>Minute</key>
        <integer>15</integer>
    </dict>
</dict>
</plist>
share|improve this question
add comment

2 Answers 2

If the program is meant to be run daily, remove the Weekday key. <key>Weekday</key><integer>1</integer> means that the program is only run on Mondays.

Also you don't need the OnDemand or RunAtLoad keys. OnDemand was deprecated in 10.5 in favor of RunAtLoad and RunAtLoad is false by default.

share|improve this answer
    
It's supposed to be run on weekdays, but I removed the additional weekday and time tags for brevity since they're all the same. Do you think the OnDemand might be causing the script not to run? –  Lido Aug 30 '13 at 15:00
    
Do I need "KeepAlive"? –  Lido Aug 31 '13 at 5:44
    
Just to make sure, did you run launchctl unload /path/to/label.plist; launchctl load /path/to/label.plist after making changes to the plist? KeepAlive is not needed when the job is invoked on demand, like by StartCalendarInterval. If you have a program that is supposed to be run at login and be started again if it terminates, you can set both RunAtLoad and KeepAlive to true. –  Lri Aug 31 '13 at 6:23
    
I did sudo unload and sudo load on the plist. That's the only entry in the log about the scripts btw. It looks like they never even "tried" to run the shell script in the Program section. –  Lido Aug 31 '13 at 14:27
add comment
up vote 0 down vote accepted

The problem was apparently that I had included ".plist" in the Label tag. The file name is "local.Daily.Backup.plist" so, following advice I read on one of the blog posts about launchd/launchctl I used the file name as the Label. Not sure why, but when I unloaded the script, took the ".plist" off the Label tag, then loaded it again, it worked. Hopefully it will continue to.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.