Start script osx launch daemon

4.6k Views Asked by At

I'm trying to run an executable on my machine (mbp retina osx mountain lion) on startup.

This is what the script looks like:

<?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>Label</key> 
    <string>com.netresponsibility.daemon</string> 
    <key>ProgramArguments</key> 
    <array> 
        <string>/usr/bin/net-responsibility</string> 
        <string>--daemon</string> 
    </array> 
    <key>OnDemand</key> 
        <true/> 
</dict> 
</plist>

I put it in the /System/Library/LaunchDaemons/ directory. It's named com.netresponsibility.daemon.plist and has the same permissions as all the others.

-rw-r--r--  1 root  wheel  420 Oct 11 12:39 com.netresponsibility.daemon.plist

When I restart the executable is not called. Any ideas as to what I'm missing?

1

There are 1 best solutions below

0
On BEST ANSWER

First, you shouldn't ever put anything in /System/Library. That path is reserved for OS X files. You should put your files in /Library/LaunchDaemons/.

Second, you need to tell the system to load your plist, it's not enough to just put it there. To do that, you use launchctl:

$ sudo launchctl load -w /Library/LaunchDaemons/com.netresponsibility.daemon.plist

For more information, man launchctl.