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 have launchd configured to run a script. This works fine for the user who installed it (me), but it relaunches the script every time I log in, while I'd like it to run as long as the computer is on (like a windows service).

Details - Location:

/Library/LaunchDaemons/com.pluuserwatcher.osx.test.plist

Contents:

<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.pluuserwatcher.osx.test</string>
    <key>Program</key>
    <string>/Users/max/Projects/PLU/Utils/userwatcher.py</string>
    <key>KeepAlive</key>
    <true/>
  </dict>
</plist>
share|improve this question
    
Are you sure it's in /Library/LaunchDaemons? The behavior you describe sounds like it's in /Library/LaunchAgents instead. –  Gordon Davisson Jul 15 '12 at 17:21
    
Yes, I loaded it with launchctl load /Library/LaunchDaemons/com.pluuserwatcher.osx.test.plist –  Maxim Khesin Jul 15 '12 at 18:19

1 Answer 1

up vote 0 down vote accepted

If you load the launchd item by running launchctl load ... as a normal user, it loads it for your user launchd instance (i.e. essentially as a LaunchAgent, so it only runs within your user login sessions. To load it into the system launchd (as a proper LaunchDaemon), use sudo launchctl load ... (or just put it in /Library/LaunchDaemons and reboot).

share|improve this answer
    
Thanks - it appears to work! Unfortunately I can't upvote for lack of reputation points :( –  Maxim Khesin Jul 16 '12 at 0:20
    
@MaximKhesin: Great! Since it worked, please mark this as the "accepted" answer (see the instructions here). –  Gordon Davisson Jul 16 '12 at 2:00

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.