Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

    
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
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

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
    
I've tried using this solution right now, but since I've upgraded to El-Capitan I cannot move files to this directory. Is there a solution for this? – Yaron Idan Jan 17 at 8:32

Your Answer

 
discard

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