launchdaemon
LaunchDaemons (and LaunchAgents)
The difference between a LaunchDaemon and a LaunchAgent is that the agent will run as any user that logs in through loginwindow, while the agent can launch even before that as the root (or another specified) user.
Example LaunchDaemon and how to activate
- Create a plist like this
<?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>KeepAlive</key> <false/> <key>Label</key> <string>net.wgratz.cpunap</string> <key>ProgramArguments</key> <array> <string>hwprefs</string> <string>cpu_nap=1</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> <key>LaunchOnlyOnce</key> <true/> </dict> </plist>
- Move it to
/Library/LaunchDaemons - Load it by executing
sudo launchctl load -w /Library/LaunchAgents/net.wgratz.cpunap.plist - Start it by executing
sudo launchctl start net.wgratz.cpunap
More Links
launchdaemon.txt · Last modified: by wolfo
