I've coded my launch daemon and a launch agent for macOS. When the app is installed, I need to run both the daemon and the agent. I place the .plist for the deamon into /Library/LaunchDaemons
and then run (as admin):
launchctl load /Library/LaunchDaemons/com.example.MyDaemon.plist
and since the plist has:
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
the daemon starts up right away.
But I'm struggling to do the same with my launch agent. Here's it's plist that I place into /Library/LaunchAgents
directory for it to start for every user and also in the login screen:
<?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>LimitLoadToSessionType</key>
<array>
<string>Aqua</string>
<string>LoginWindow</string>
</array>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.example.MyAgent.plist</string>
<key>Program</key>
<string>/Library/PrivilegedHelperTools/com.example/MyAgent</string>
<key>ProgramArguments</key>
<array>
<string>-d</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
when I try to run it as:
launchctl load /Library/LaunchAgents/com.example.MyAgent.plist
I get an error:
Warning: Expecting a LaunchDaemons path since the command was ran as root. Got LaunchAgents instead.
launchctl bootstrap
is a recommended alternative. /Library/LaunchAgents/com.example.MyAgent.plist: Path had bad ownership/permissions Load failed: 122: Path had bad ownership/permissions
what am I doing wrong?