User Tools

Site Tools


You are not allowed to perform this action
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

  1. 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>
  2. Move it to /Library/LaunchDaemons
  3. Load it by executing sudo launchctl load -w /Library/LaunchAgents/net.wgratz.cpunap.plist
  4. Start it by executing sudo launchctl start net.wgratz.cpunap
launchdaemon.txt · Last modified: by wolfo

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki