9 Replies Latest reply: Dec 18, 2009 7:40 AM by Ashland1381
bemike Level 1 Level 1 (0 points)
Hi guys,

Honestly this problem drives me crazy, I just can't find a way to stop launchd to write logs to syslog, and the every-10-seconds messages flooded my console which makes barely see other userful information.

Here's my situation, I use launchd to autostart autossh and keep it alive as long as there's a network connection. My setting:

<?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>KeepAlive</key>
<dict>
<key>NetworkState</key>
<true/>
</dict>
<key>Label</key>
<string>any.file.name</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/autossh</string>
<string>-M20008</string>
<string>-f</string>
<string>-q</string>
<string>-N</string>
<string>-D</string>
<string>7777</string>
<string>username@domain.tld</string>
</array>
<key>StandardOutPath</key>
<string>/dev/null</string>
<key>StandardErrorPath</key>
<string>/dev/null</string>

</dict>
</plist>

The problem is the KeepAlive key makes launchd output a message to syslog every 10 secs and flooded my console, you can have a look at: http://bit.ly/1UwTHx

I try to run: launchctl log level emergency but it doesn't work. And apparently neither StandardErrorPath nor StandardOutPath is helping.

Guys, is there any way I can stop my console being flooded by launchd? Thank you very much in advance!

Michael

Macbook Pro 13, Mac OS X (10.6.1)
  • 1. Re: How to stop launchd writing output to syslog?
    Barney-15E Level 8 Level 8 (35,275 points)
    It is writing a message continuously because the script is failing to start and you told it to keep alive.
    So, your launchctl script calls autossh, it fails, logs the failure, and then tries to start it again. Repeat indefinitely.

    You need to figure out why your script is failing and fix it.
  • 2. Re: How to stop launchd writing output to syslog?
    V.K. Level 9 Level 9 (56,120 points)
    I'm not familiar with autossh but looking at their homepage
    http://www.harding.motd.ca/autossh/
    it's clear that you only need to run autossh once and it will keep the ssh connection open and restart itself if necessary.
    this is the whole point of this program.
    this means that a launch daemon like yours is not necessary at all and in fact might be screwing things over by trying to run it over and over. just get rid of it or make a launch daemon that launches autossh once when you log in.
  • 3. Re: How to stop launchd writing output to syslog?
    bemike Level 1 Level 1 (0 points)
    Thanks V.K. I'll try removing KeepAlive from the startup script.
  • 4. Re: How to stop launchd writing output to syslog?
    bemike Level 1 Level 1 (0 points)
    Er... Removing KeepAlive brings another problem: I actually wanted to let autossh restart itself when network connection becomes active. But without KeepAlive it won't, I need to restart it manually when network connection from inactive to active.

    Is there a solution for that?
  • 5. Re: How to stop launchd writing output to syslog?
    Barney-15E Level 8 Level 8 (35,275 points)
    If it can't connect because the network connection isn't available, it will quit and your script will restart it.

    Your original post with the screenshot shows that something is already running on that port. That is why it is failing. You're going to have to get ssh and autossh working before you try controlling it with a launchctl script.
  • 6. Re: How to stop launchd writing output to syslog?
    Robert M Frank Level 1 Level 1 (5 points)
    I'm just starting to mess around with launchd too. This is something to consider:

    - does autossh 'daemonize' istelf (i.e. does it do a fork, close file descriptors, etc)?
    If it does, lauchd thinks it failed and will restart it immediately. Get rid of any daemonizing [that is the default way for normal unix/linux - but not for Mac OS - cf man launchd.plist(5) ]
    - there is a keepAlive option to check for network connection, again man aunchd.plist(5) and check for NetworkState
  • 7. Re: How to stop launchd writing output to syslog?
    Robert M Frank Level 1 Level 1 (5 points)
    (The message got interpreted!)
    I'm just starting to mess around with launchd too. This is something to consider:

    Does autossh 'daemonize' istelf (i.e. does it do a fork, close file descriptors, etc)?
    If it does, lauchd thinks it failed (because the parent process will exit) and will restart it immediately. Get rid of any daemonizing (i.e. daemonize, fork; that is the default way for normal unix/linux - but not for Mac OS - cf man launchd.plist(5) )

    There is a keepAlive option to check for network connection, again man aunchd.plist(5) and check for NetworkState
  • 8. Re: How to stop launchd writing output to syslog?
    Ashland1381 Level 1 Level 1 (0 points)
    I contacted Parallels Support and told me to uninstall. I did and the messages continued. So I
    look for the info in the messages and trashed them and rebooted after the first uninstall and the
    after I trashed the com.parallels files, I rebooted again. I sent all the info off to Parallels support
    before I take the time to reinstall. The mind set right now is to ask for the money back
    or give the license away. If I need windows, I will reinstall Bootcamp/Win7 or use
    the Dell Win7 system.

    Boot camp is ok but right now Win7 and Bootcamp are not on the same page with drivers etc.
  • 9. Re: How to stop launchd writing output to syslog?
    Ashland1381 Level 1 Level 1 (0 points)
    I did the uninstall as Parallels support suggested but the syslog messages, every 10 seconds continued. So I searched for launhd's and found several and removed them which Parallels confirmed. Go to MacHD/Library or MacHD/Users/homefolder/Library and trash the Launch Agents and LauncDaemons.

    On the reinstall, all worked well, no syslog error messages.
    I used the custom install versus express or typical.