launchctl/plist/launchdaemons on snow leopard

Joined
Nov 11, 2009
Messages
2
Reaction score
0
Points
1
hello,

i have to create a daemon on a Mac OSX. the daemon must start when the Mac boots up. i have therefore wrote a daemon (using RealBasic), and also wrote a plist file which points to the daemon. everything has been running just fine on Mac OSX 10.4 for months. Now i have copied everything to Snow Leopard 10.6 and am having a small problem. let me explain what i have done so far.

1) i have created a plist file, called "myTestDaemon.plist", which lives in system/library/launchdaemons. the file is exactly this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
	"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>myNewTestDaemon</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Users/Paul/Desktop/RealBasic_Projects/My_Application</string>
	</array>
	<key>RunAtLoad</key>
	<true/>	
</dict>
</plist>

2) as the above file describes, i have put the daemon, called "myNewTestDaemon", inside /Users/Paul/Desktop/RealBasic_Projects/My_Application

3) i can then start the daemon using one of two methods - either by rebooting the Mac, in which case the launchd system tool automatically starts the daemon, or by starting the daemon manually using launchctl:

Code:
sudo launchctl load /system/library/launchdaemons/myTestDaemon.plist

once i do either of the two above methods, i can verify that the daemon is started by doing:

Code:
sudo launchctl list

and this shows that myTestDaemon.plist is indeed running.

now, i have done exactly the same thing on my shiney new Mac mini with Snow Leopard on it, but when i do the "launchctl load ...." command, it gives me an error:

Code:
"nothing found to load"

after a bit of snooping on the net i found that some people were saying that i have to add a "-F" flag to the command, so now it reads:

Code:
sudo launchctl load -F /system/library/launchdaemons/myTestDaemon.plist

apparantly, all plists have a default key called "Disabled", which, if you do not explicitly set to false, is set to true by default. setting the -F flag tells launchctl to ignore this Disabled key, which effectively makes Disable=false. so, i tried the above command with the -F flag and sure enough, this time my daemon started.

so i then explicitly added the key to my plist:

Code:
<key>Disabled</key>
<false/>

surely this should have the same affect ? apparantly not, because i still get the orginal "nothing found to load" error when i do the "launchctl load...." (without the -F flag). in addition, the daemon still does not start when the Mac boots up. and this is my problem.

like i say, this was all working in 10.4, and now not working in 10.6. So i imagine something has changed between version ? does my plist file look right ? all i need the daemon to do is start up at boot time.

hope i have explained it well. if not please ask for more info.

any help appreciated.
 
Joined
May 2, 2009
Messages
480
Reaction score
13
Points
18
Your Mac's Specs
MBP 2.33 4GB: MacPro 8 Core 2.8, 16GB: MacMini 2.26 4GB: MacMin 2.53 4GB: iPhone3GS 32GB
Have a look at this:

launchctl disabled key in 10.6? - macenterprise | Google Groups

You may want to take a look at the /private/var/db/launchd.db/com.apple.launchd/overrides.plist file. Sounds like you service may have ended up there somehow. Thats the only thing I can think of. Everything else looks ok.

Also, you may want to look at the logs in the /Applications/Utilities/Console application. Typically launchctrl gives extended information in the console logs.

Oh, and welcome to the forums!
 
Joined
Dec 8, 2009
Messages
1
Reaction score
0
Points
1
Hi-
I am having this same problem. Did you ever figure out how to make it work?
Thanks!
 
OP
U
Joined
Nov 11, 2009
Messages
2
Reaction score
0
Points
1
Hi-
I am having this same problem. Did you ever figure out how to make it work?
Thanks!

right - this was ages ago, and i did get to the bottom of it but i cant remember what i did exactly :Confused:

heres the plist that im currently using, maybe it was extra keep-alive and disabled flags that made it work?

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
	"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>MyClientService</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Users/me/Desktop/RealBasic_Projects/Test/MyClientService</string>
	</array>
	<key>KeepAlive</key>
	<true/>	
	<key>Disabled</key>
	<false/>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>

sorry i cant be of any more help, the project has been put on hold since i posted last so its been ages since i actually played around with this - good luck ;)
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top