Launchctl problems

Hi everyone,

Having a little problem setting up launchctl to load my nginx.plist.

I've got a file called:

/System/Library/LaunchDaemons/nginx.plist

with the contents:

<?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>nginx</string>
<key>Program</key><string>/usr/local/nginx/sbin/nginx</string>
<key>KeepAlive</key><true/>
<key>NetworkState</key><true/>
<key>StandardErrorPath</key><string>/var/log/system.log</string>
<key>LaunchOnlyOnce</key><true/>
</dict>
</plist>

And I issue the command in terminal:

launchctl load -F /System/Library/LaunchDaemons/nginx.plist

Doesn't show any output. So I then call:

launchctl list | grep nginx

which gives me nothing. I was wondering if anyone can see what I'm doing wrong?

- James.

Mac OS X (10.6.2)

Posted on Nov 23, 2009 3:15 AM

Reply
4 replies

Nov 23, 2009 3:48 AM in response to James Hiscock

I don't ever remember launchctl giving any sort of feedback on successfully loading a configuration file. One can of course always test if the job succeeded by using *echo $0* immediately after the *launchctl load* command. As for listing the jobs, if listing all the launch daemons/agents doesn't work maybe you can try listing only the nginx daemon.
launchctl list nginx

This should output the settings as given in your plist file. (Using the -x flag before the label of your deamon will give the output as an XML file.) Since this is a launch daemon you might also want to run this command as a superuser through sudo.

Nov 23, 2009 10:36 AM in response to James Hiscock

Just a few points:

James Hiscock wrote:
I've got a file called:

/System/Library/LaunchDaemons/nginx.plist


There's no advantage in placing a plist in /System/Library/LaunchDaemons over placing it in /Library/LaunchDaemons, and you run risks of opening security holes and interfering with core tasks. The system area is for apple's use, and you shouldn't use it without an awfully good reason.

James Hiscock wrote:
<key>Label</key><string>nginx</string>


well, apple is expecting a reverse domain name label, and giving it something without dots might be confusing launchctl (because your list | grep command should have worked). try 'my.nginx'.
James Hiscock wrote:
launchctl load -F /System/Library/LaunchDaemons/nginx.plist


the -F option is unneeded (you don't have the disabled key set)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Launchctl problems

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.