Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

rsyncd plist for launchd -- not starting properly on reboot.

I have a plist in /Library/LaunchDaemons which starts an rsync deamon. That is, it starts an rsync daemon if I start it manually with sudo launchctl load rsyncd.plist.

But when I reboot the server and try to connect to the deamon I get (on the client machine)

rsync: server sent "launchproxy[1928]: execv(): No such file or director" rather than greeting

I have to manually reload the launch daemon on the server machine using using
sudo launchctl unload /Library/LaunchDaemons/rsyncd.plist
sudo launchctl load /Library/LaunchDaemons/rsynd.plist

Any ideas? Here is my rysncd.plist, I mostly copied it from an example on the interwebs.

<?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>Disabled</key>
<false/>
<key>Label</key>
<string>rsync</string>
<key>Program</key>
<string>/opt/local/bin/rsync</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/rsync</string>
<string>--daemon</string>
</array>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>rsync</string>
<key>SockType</key>
<string>stream</string>
</dict>
</dict>
</dict>
</plist>

Mac Pro 2008 / iMac 2009/ Mini 2008 / Macbook 2009, Mac OS X (10.6.2)

Posted on May 31, 2010 9:12 AM

Reply
Question marked as Best reply

Posted on May 31, 2010 10:12 AM

There are several problems with your .plist, so it's hard to know which one is causing the problem.

For one you have both a Program and a ProgramArguments key, when you should have only one or the other (you use Program if there is just one element to the command, or ProgramArguments if there are multiple.

Beyond that, though, it's not clear which execution model you're trying to use. launchd can run tasks either on demand (i.e. when some event happens that triggers the process to launch) or continuously (where launchd watches the process and automatically restarts it if it fails).

The fact you're specifying network sockets would normally indicate that you're running on demand (i.e. launchd should start rsync whenever an incoming network connection is detected). However, your ProgramArguments includes a --daemon parameter to rsync, which tells it to run continuously and listen for network connections itself. These options are incompatible (i.e. either launchd or rsync can listen to the network, but not both).

You should decide which model to employ - either let launchd listen to the network and run rsync as needed, or run rsync as a daemon and let it listen to the network.

As I said above, it isn't clear which (if either) of these is the root cause of your problem, but they need to be fixed before any more debugging can take place.
8 replies
Question marked as Best reply

May 31, 2010 10:12 AM in response to jabraham

There are several problems with your .plist, so it's hard to know which one is causing the problem.

For one you have both a Program and a ProgramArguments key, when you should have only one or the other (you use Program if there is just one element to the command, or ProgramArguments if there are multiple.

Beyond that, though, it's not clear which execution model you're trying to use. launchd can run tasks either on demand (i.e. when some event happens that triggers the process to launch) or continuously (where launchd watches the process and automatically restarts it if it fails).

The fact you're specifying network sockets would normally indicate that you're running on demand (i.e. launchd should start rsync whenever an incoming network connection is detected). However, your ProgramArguments includes a --daemon parameter to rsync, which tells it to run continuously and listen for network connections itself. These options are incompatible (i.e. either launchd or rsync can listen to the network, but not both).

You should decide which model to employ - either let launchd listen to the network and run rsync as needed, or run rsync as a daemon and let it listen to the network.

As I said above, it isn't clear which (if either) of these is the root cause of your problem, but they need to be fixed before any more debugging can take place.

May 31, 2010 10:45 AM in response to Camelot

Ok that helps a lot, thanks.

I'll remove the Program part and just use ProgramArguments.

I think I'd like to use rsync's own daemon capability, with --daemon. I'm familiar with it, and it seems to work reliably once started (at least on my unix boxes). So I should remove the network sockets part, and maybe add a keepalive part?

I thought a read somewhere about some parameter to launchd that tells the program to start after all the network services are started. Do I need something like that? Or am I mis-remembering?

--
John

May 31, 2010 10:57 AM in response to jabraham

I think I'd like to use rsync's own daemon capability, with --daemon. I'm familiar with it, and it seems to work reliably once started (at least on my unix boxes). So I should remove the network sockets part, and maybe add a keepalive part?


If that's the way you want to go, then sure. 🙂

I thought a read somewhere about some parameter to launchd that tells the program to start after all the network services are started. Do I need something like that? Or am I mis-remembering?


There is no specific dependency model in launchd, but there are some KeepAlive options that might help - specifically the NetworkState key which will keep your process running as long as there's an active network connection, and shut it down when the network is offline.


<key>KeepAlive</key>
<dict>
<key>NetworkState</key>
<true/>
</dict>

May 31, 2010 4:30 PM in response to Camelot

I'm trying this. Much simpler, might work:

<?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>Disabled</key>
<false/>
<key>Label</key>
<string>rsync</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/rsync</string>
<string>--daemon</string>
</array>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad></key>
<true/>
</dict>
</plist>

Jun 1, 2010 10:08 AM in response to jabraham

That new simplified didn't work. I still get

rsync: server sent "launchproxy[2620]: execv(): No such file or directory" rather than greeting

as an error trying to connect to the daemon from another machine after rebooting the server. On the server I have to do

sudo launchctl unload /Library/LaunchDaemons/rsyncd.plist; sudo launchctl load /Library/LaunchDaemons/rsyncd.plist

after every reboot, before it will work.

--
John

Aug 16, 2010 12:23 PM in response to jabraham

Just to follow up, this seems to be working now. Here is my plist:

<?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>Disabled</key>
<false/>
<key>Label</key>
<string>rsync</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/rsync</string>
<string>--daemon</string>
</array>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>RunAtLoad></key>
<true/>
</dict>
</plist>

Aug 20, 2010 11:24 AM in response to jabraham

I'm not sure that I remember the exact wording, but I believe launchd cannot start processes that detach from the terminal (?) they spawn from. (Someone please correct me if I have this description wrong.) Because of that, rsync can't be daemonized from launchd. You'll have to create a StartupItem for it. Looking at my own servers, I see IPFailover, QuickTimeStreamingServer, and SiCoreService all still require StartupItems.

rsyncd plist for launchd -- not starting properly on reboot.

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