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 put my plist in /Library/LaunchAgents and my exexutive program in /usr/libexec and daemon statrs when system startup . But this daemon is owned by user . I try to put my plist in /Library/LauchDaemons but it's not working and daemon doesn't starts in system startup

I want to know how to make a daemon launch as root when system starts up.What additional jobs should I do to make a daemon launch as root ? Thanks in advance!

share|improve this question
    
launchd does exactly what you need. –  CodaFi Mar 28 '13 at 7:01
    
What do you mean? What should I do? I can start a daemon with launchctl load coomand oon terminal . But the daemon lifetime is not over a restart . After the system is rebooted daemon is not launching. –  mohammad Mar 28 '13 at 7:05
add comment

migrated from stackoverflow.com Mar 29 '13 at 12:37

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 4 down vote accepted

After you put plist in /Library/LaunchDaemons you need to run command sudo launchctl load -w /Library/LaunchDaemons/your.plist
See man launchctl for the -w flag (it does exactly what you need)
Edit: did you set the RunAtLoad key to true in your plist?
Edit2: I forgot, RunAtLoad has no influence on autolaunch, it is all bout Disabled key.

share|improve this answer
    
I try this but give me this error : launchctl: Dubious ownership on file (skipping): /Library/LaunchDaemons/com.apple.mydaemon.plist nothing found to load –  mohammad Mar 28 '13 at 7:12
    
They probably don't like you using com.apple in there. –  Randy Howard Mar 28 '13 at 7:13
    
You plist must be owned by root:wheel and have 0644 mod (-rw-r--r--) –  cody Mar 28 '13 at 7:14
    
What exactly should I do to make it work? I will be appreciated if you help me to solve this issue –  mohammad Mar 28 '13 at 7:20
    
sudo chown root:wheel your.plist and sudo chmod 0644 your.plist –  cody Mar 28 '13 at 7:21
show 4 more comments

Change the directory where you put your plist, like this:

/System/Library/LaunchDeamon

This directory was read from Launchd before the startup of user.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.