nohup does not work! - Unix

This is a discussion on nohup does not work! - Unix ; I am asking this again. The problem hasn't been solved. I've tried different shells like csh, ksh, sh, bash. None of them helped. Here is my Mandrake system info: [me@myhost]$ uname -a Linux my.domain.com 2.4.22-10mdkenterprise #1 SMP Thu Sep 18 ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: nohup does not work!

  1. nohup does not work!

    I am asking this again. The problem hasn't been solved. I've tried
    different shells like csh, ksh, sh, bash. None of them helped.

    Here is my Mandrake system info:

    [me@myhost]$ uname -a
    Linux my.domain.com 2.4.22-10mdkenterprise #1 SMP Thu Sep 18 11:46:49
    CEST 2003 i686 unknown unknown GNU/Linux

    A program of mine takes more than 12 hours to run. So I did the
    following
    from the SSH (R) Secure Shell 3.2.9 terminal:

    [me@myhost]$ nohup ./myapplication &

    And then I see this:

    [me@myhost] nohup: appending output to `nohup.out'

    Then if I do

    ps efu

    I do see that the program is running.

    So, I logged out.

    Then I logged in, just to make sure that the process is still running.
    But only to find that it has been killed.

    I've tried this many times, and just cannot get it to work. I googled
    hard, but could not find a solution.

    Could anyone please help?


  2. Re: nohup does not work!

    antonyliu2002@yahoo.com wrote:

    > $ nohup ./myapplication &
    > [...]
    > I do see that the program is running.
    >
    > So, I logged out.
    > Then I logged in, just to make sure that the process is still running.
    > But only to find that it has been killed.


    Does your application reinitialize its signal handler,
    thus "overriding" nohup? (compare your command and
    "/bin/sleep" for example, starting each with nohup
    and then siganlling both with "kill -HUP".)

  3. Re: nohup does not work!

    On 10 May 2006 07:29:50 -0700, antonyliu2002@yahoo.com wrote:
    > I am asking this again. The problem hasn't been solved. I've tried
    > different shells like csh, ksh, sh, bash. None of them helped.
    >
    > Here is my Mandrake system info:
    >
    > [me@myhost]$ uname -a
    > Linux my.domain.com 2.4.22-10mdkenterprise #1 SMP Thu Sep 18 11:46:49


    Hmm, looks like an old release. You may want to read
    http://www.mandriva.com/security/productlifetime
    I would also guess you are missing a bunch of security updates.


    > CEST 2003 i686 unknown unknown GNU/Linux
    >
    > A program of mine takes more than 12 hours to run. So I did the
    > following
    > from the SSH (R) Secure Shell 3.2.9 terminal:
    >
    > [me@myhost]$ nohup ./myapplication &
    >
    > And then I see this:
    >
    > [me@myhost] nohup: appending output to `nohup.out'
    >
    > Then if I do
    >
    > ps efu
    >
    > I do see that the program is running.
    >
    > So, I logged out.
    >
    > Then I logged in, just to make sure that the process is still running.
    > But only to find that it has been killed.
    >
    > Could anyone please help?


    Your only options are:
    o put print statements in the code to find out where it dies.

    o try something like
    nohup ./myapplication > $HOME/myapp.log 2>&&
    hoping $HOME/myapp.log will have something.
    o Create an /at/ batch or a cron script hoping the app will run or at
    least give you more information.

    o Contact the vendor/coder for help if not your code.

  4. Re: nohup does not work!

    antonyliu2002@yahoo.com wrote:
    > I am asking this again. The problem hasn't been solved. I've tried
    > different shells like csh, ksh, sh, bash. None of them helped.
    > Here is my Mandrake system info:
    > [me@myhost]$ uname -a
    > Linux my.domain.com 2.4.22-10mdkenterprise #1 SMP Thu Sep 18 11:46:49
    > CEST 2003 i686 unknown unknown GNU/Linux
    > A program of mine takes more than 12 hours to run. So I did the
    > following
    > from the SSH (R) Secure Shell 3.2.9 terminal:
    > [me@myhost]$ nohup ./myapplication &
    > And then I see this:
    > [me@myhost] nohup: appending output to `nohup.out'
    > Then if I do
    > ps efu
    > I do see that the program is running.
    > So, I logged out.
    > Then I logged in, just to make sure that the process is still running.
    > But only to find that it has been killed.
    > I've tried this many times, and just cannot get it to work. I googled
    > hard, but could not find a solution.


    Are you sure it was "killed"? Maybe it committed suicide. Perhaps it
    doesn't like losing the controlling terminal, or there's something
    else that changes when you log out that it doesn't like.

    If the process ceases to exist that quickly after logging out and the
    problem is highly reproducible, it should be relatively easy to track
    down.

    Start with the easy stuff - what's the exit value from the process?
    That may tell you why/how it died. If you get an exit value >=128, you
    can subtract 128 from the exit value, and that should give you the
    number of the signal that killed it, e.g.:
    $ { sleep 999; echo $? >exitval; } &
    [1] 25257
    $ type sleep
    sleep is /bin/sleep
    $ fuser -15 -k /bin/sleep
    /bin/sleep: 25258e
    -bash: line 2395: 25258 Terminated sleep 999
    [1]+ Done { sleep 999; echo $? >exitval; }
    $ expr $(cat exitval) - 128
    15
    $ kill -l
    1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
    5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE
    9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
    13) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD
    18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN
    22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
    26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO
    30) SIGPWR 31) SIGSYS 33) SIGRTMIN 34) SIGRTMIN+1
    35) SIGRTMIN+2 36) SIGRTMIN+3 37) SIGRTMIN+4 38) SIGRTMIN+5
    39) SIGRTMIN+6 40) SIGRTMIN+7 41) SIGRTMIN+8 42) SIGRTMIN+9
    43) SIGRTMIN+10 44) SIGRTMIN+11 45) SIGRTMIN+12 46) SIGRTMIN+13
    47) SIGRTMIN+14 48) SIGRTMIN+15 49) SIGRTMAX-15 50) SIGRTMAX-14
    51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10
    55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6
    59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
    63) SIGRTMAX-1 64) SIGRTMAX
    $ cat .foo
    flags="$-"
    set +m
    for sig in 1 2 3 9 15; do
    [ -f exitval ] && rm exitval
    { sleep 999; echo $? >exitval; } &
    sleep 2
    >>/dev/null 2>&1 fuser -$sig -k /bin/sleep

    sleep 2
    echo -n "signal: $sig, exit value - 128 = "
    if [ -s exitval ]; then
    expr $(cat exitval) - 128
    else
    echo "didn't get non-zero length file"
    fi
    done; unset sig
    set -"$flags"; unset flags
    $ . ./.foo
    -bash: line 15: 26311 Hangup sleep 999
    signal: 1, exit value - 128 = 1
    signal: 2, exit value - 128 = 2
    -bash: line 15: 26329 Quit sleep 999
    signal: 3, exit value - 128 = 3
    -bash: line 15: 26338 Killed sleep 999
    signal: 9, exit value - 128 = 9
    -bash: line 15: 26347 Terminated sleep 999
    signal: 15, exit value - 128 = 15
    $

    In some cases you may find the process was "signalled", e.g. by one of:
    4) SIGILL
    7) SIGBUS
    11) SIGSEGV
    that would typically indicate the program tried to do something bad,
    and was zapped in the process.

    If the exit values still don't provide enough hints, there's
    strace(1), e.g.:
    $ nohup strace strace_options_and_option_arguments ./myapplication &
    With suitable strace_options_and_option_arguments that should narrow
    down why the program is exiting or what's causing it to do so.

    In the case of "myapplication", one could also put relevant
    diagnostic/debugging code in myapplication to further investigate
    what's happening.

    You might also try LINUX and/or Madrake news group(s). Much of what I
    suggested is relatively generic to UNIX, but some of it is more
    specific to LINUX and/or bash(1) behavior.

    I rather doubt nohup isn't working. Have you tested sending the
    SIGHUP signal to a process which is, and one which isn't, "protected"
    by nohup? It seems much more likely the problem resides with your
    "./myapplication", or the manner in which you're using or attempting
    to use it. You can also try these tests with your ./myapplication
    to determine if nohup is indeed acting as expected. You may want to
    use kill, rather than fuser (I was just being "lazy" in not looking up
    the PID for sleep each time).

    $ { sleep 999; echo $? >exitval; } &
    [1] 26455
    $ fuser -1 -k /bin/sleep
    /bin/sleep: 26456e
    -bash: line 2442: 26456 Hangup sleep 999
    $ expr $(cat exitval) - 128
    1
    $ rm exitval
    $ { nohup sleep 999; echo $? >exitval; } &
    [1] 26462
    $ nohup: appending output to `nohup.out'
    fuser -1 -k /bin/sleep
    /bin/sleep: 26463e
    $ ls -l exitval
    ls: exitval: No such file or directory
    $ fuser -1 -k /bin/sleep
    /bin/sleep: 26463e
    $ ls -l exitval
    ls: exitval: No such file or directory
    $ fuser -15 -k /bin/sleep
    /bin/sleep: 26463e
    -bash: line 2448: 26463 Terminated nohup sleep 999
    $ expr $(cat exitval) - 128
    15
    $


  5. Re: nohup does not work!

    >antonyliu2002@yahoo.com wrote:
    >> A program of mine takes more than 12 hours to run. So I did the
    >> following
    >> from the SSH (R) Secure Shell 3.2.9 terminal:
    >> [me@myhost]$ nohup ./myapplication &
    >> And then I see this:
    >> [me@myhost] nohup: appending output to `nohup.out'
    >> Then if I do
    >> ps efu
    >> I do see that the program is running.
    >> So, I logged out.
    >> Then I logged in, just to make sure that the process is still running.
    >> But only to find that it has been killed.


    Are you doing this on your own machine, or ssh'ing to a remote host?
    If the latter then quite possibly sysadm has it set to kill a user's
    running processes when you log out and you can't change this.
    --
    John Savage (my news address is not valid for email)


+ Reply to Thread