I wrote a little script to automatically update my Network Location based on a couple of conditions, and have coupled that with a launchd plist to have it run every couple of minutes.
However, I've noticed that my launchd plist doesn't seem to get loaded when my computer reboots. My plist is in ~/Library/LaunchDaemons
and is fairly simple:
<?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.davedelong.location-updater</string>
<key>Program</key>
<string>/path/to/my/location_updater.rb</string>
<key>StartInterval</key>
<integer>180</integer>
</dict>
</plist>
My LaunchDaemons
folder has the expected 700
permissions, and running launchctl load
with my plist makes things work just fine. It's just that when I reboot, it's not getting loaded.
I was under the impression that everything in ~/Library/LaunchDaemons
and ~/Library/LaunchAgents
got loaded automatically by launchd. Is this not the case? If this is the case (and I think it is), then why isn't my plist getting loaded?
Best Answer
~/Library/LaunchDaemons
isn't a valid location for either launch agents or launch daemons. You are misunderstanding the terminology. LaunchDaemons are system-wide processes, while LaunchAgents are run per-user. From the launchd man page:Move your plist to
~/Library/LaunchAgents
, and it should just work.