Re: Starting daemon using ssh

From: Greg Wooledge (wooledg_at_eeg.ccf.org)
Date: 11/04/04

  • Next message: Kieran.Tully AT acm.org: "Re: Starting daemon using ssh"
    Date: Thu, 4 Nov 2004 07:51:28 -0500
    To: "Binninger, Martin" <martin.binninger@burdadigital.de>
    
    

    On Tue, Nov 02, 2004 at 08:19:39AM +0100, Binninger, Martin wrote:
    > While trying, to start a daemon on a remote machine using ssh, the client
    > doesn't return to the local prompt after performing the start-up of the
    > daemon.

    This question seems to come up at least once a month.

    imadev:~$ time ssh localhost 'sleep 20 &'
    wooledg@localhost's password:

    real 0m22.757s
    user 0m0.080s
    sys 0m0.020s

    imadev:~$ time ssh localhost 'sleep 20 >/dev/null 2>&1 &'
    wooledg@localhost's password:

    real 0m2.298s
    user 0m0.080s
    sys 0m0.020s
    imadev:~$ ps -ef | grep sleep
     wooledg 26650 11055 0 07:49:21 pts/1 0:00 grep sleep
     wooledg 26648 1 0 07:49:17 ? 0:00 sleep 20

    Any more questions?

    Fix your daemon-starting scripts. Don't leave file descriptors
    hanging. Redirect everything to a logfile. In Bourne shell syntax,
    you can do that like this:

    #!/bin/sh

    PATH=....
    export PATH

    exec >>/var/log/whatever 2>&1

    case "$1" in
        start) .... ;;
        stop) .... ;;
        ....
    esac


  • Next message: Kieran.Tully AT acm.org: "Re: Starting daemon using ssh"