Using 'nohup' w/o keeping session open

Using 'nohup' w/o keeping session open

Post by wang, Zose » Tue, 23 Feb 1999 04:00:00



Pls help me setup environment to let back ground job running w/o keep my
terminal session open by using 'nohup'.

Thanks in advance


 
 
 

Using 'nohup' w/o keeping session open

Post by K.Lockhof » Wed, 24 Feb 1999 04:00:00



> Pls help me setup environment to let back ground job running w/o keep my
> terminal session open by using 'nohup'.

nohup backgroundjob &

 
 
 

Using 'nohup' w/o keeping session open

Post by wang, Zose » Thu, 25 Feb 1999 04:00:00


This only submit the background jobs. If you exit the terminal session the
background will exit also.

Thanks anyway




> > Pls help me setup environment to let back ground job running w/o keep my
> > terminal session open by using 'nohup'.

> nohup backgroundjob &

 
 
 

Using 'nohup' w/o keeping session open

Post by His Holiness the Reverend Doktor Xenophon Fenderson, the Carbon(d)ate » Thu, 25 Feb 1999 04:00:00


    wZ> This only submit the background jobs. If you exit the terminal
    wZ> session the background will exit also.

Since when?  'nohup foo &' will run the command foo to completion,
even if the controlling terminal hangs up (hence the term 'nohup').
You might want to also redirect I/O to disk, e.g. 'nohup foo 2>&1 >
foo.out &' (dunno if I got the redirection right, look it up in the
manpage to be certain).

But nohup *does* work as advertised, and on a lot more systems than
just NetBSD (e.g. Linux, Solaris, NeXTstep).

--
Rev. Dr. Xenophon Fenderson, the Carbon(d)ated, KSC, DEATH, SubGenius, mhm21x16
Pope, Patron Saint of All Things Plastic fnord, and Salted Litter of r.g.s.b
"When I was a kid, I used to think that Dammit was God's last name, just like
Christ is Jesus' last name." - Kimberly Chapman in rec.humor.oracle.d

 
 
 

Using 'nohup' w/o keeping session open

Post by Tobias Bro » Tue, 02 Mar 1999 04:00:00



> This only submit the background jobs. If you exit the terminal session the
> background will exit also.

No? Perhaps your BOFH is running a script killing all your background
jobs when you log out? At least nohup has always worked for me.

Alternatively you can use the "disown" command if you switch shell to
zsh. I've also seen the command "detach".

Yet another alternativ .. if you are running interactive terminal
programs, you might have a peek at screen(1). Anyway, many BOFHs kill
or disable screen. At NetBSD, I've seen the computer running out of
ttyps disallowing logins due to too many screen processes.

Be sure always to use nice(1) when running processes overnight, it
decreases the risk of your processes getting killed by a BOFH.

--
TobiX                   In a world without fences, who needs gates?
http://www.td.org.uit.no/~tobias/

 
 
 

Using 'nohup' w/o keeping session open

Post by Zosen Wan » Tue, 02 Mar 1999 04:00:00


This is exactly my problem. I had this experience on different Unix machines. Must
machines work as you said - I could use nohup, hang up my terminal and job can
finish w/o problem. On some machines, the background jobs terminated immediately,
if  I hang up my session. I think it is related with OS installation or environment
setup.

I experienced this scenario on different HP-UX and SVR4 machines but not all. I
asked the Unix admin and they know nothing about it.



>     wZ> This only submit the background jobs. If you exit the terminal
>     wZ> session the background will exit also.

> Since when?  'nohup foo &' will run the command foo to completion,
> even if the controlling terminal hangs up (hence the term 'nohup').
> You might want to also redirect I/O to disk, e.g. 'nohup foo 2>&1 >
> foo.out &' (dunno if I got the redirection right, look it up in the
> manpage to be certain).

> But nohup *does* work as advertised, and on a lot more systems than
> just NetBSD (e.g. Linux, Solaris, NeXTstep).

> --
> Rev. Dr. Xenophon Fenderson, the Carbon(d)ated, KSC, DEATH, SubGenius, mhm21x16
> Pope, Patron Saint of All Things Plastic fnord, and Salted Litter of r.g.s.b
> "When I was a kid, I used to think that Dammit was God's last name, just like
> Christ is Jesus' last name." - Kimberly Chapman in rec.humor.oracle.d

 
 
 

Using 'nohup' w/o keeping session open

Post by Zosen Wan » Tue, 02 Mar 1999 04:00:00


This is exactly my problem. I had this experience on different Unix machines. Must
machines work as you said - I could use nohup, hang up my terminal and job can
finish w/o problem. On some machines, the background jobs terminated immediately,
if  I hang up my session. I think it is related with OS installation or environment
setup.

I experienced this scenario on different HP-UX and SVR4 machines but not all. I
asked the Unix admin and they know nothing about it.



>     wZ> This only submit the background jobs. If you exit the terminal
>     wZ> session the background will exit also.

> Since when?  'nohup foo &' will run the command foo to completion,
> even if the controlling terminal hangs up (hence the term 'nohup').
> You might want to also redirect I/O to disk, e.g. 'nohup foo 2>&1 >
> foo.out &' (dunno if I got the redirection right, look it up in the
> manpage to be certain).

> But nohup *does* work as advertised, and on a lot more systems than
> just NetBSD (e.g. Linux, Solaris, NeXTstep).

> --
> Rev. Dr. Xenophon Fenderson, the Carbon(d)ated, KSC, DEATH, SubGenius, mhm21x16
> Pope, Patron Saint of All Things Plastic fnord, and Salted Litter of r.g.s.b
> "When I was a kid, I used to think that Dammit was God's last name, just like
> Christ is Jesus' last name." - Kimberly Chapman in rec.humor.oracle.d

 
 
 

Using 'nohup' w/o keeping session open

Post by Tobias Bro » Fri, 05 Mar 1999 04:00:00



> I experienced this scenario on different HP-UX and SVR4 machines but not all. I
> asked the Unix admin and they know nothing about it.

Very strange, indeed. This problem has to be tracked down. First of
all, try the other hints described in my other posts; try to use
screen, and detach it (default by control-a control-d). Log out, then
immediately back in, and try to resume the screen with "screen -r".

Check if the "detach" command exists.

Check if they have zsh, try this (just paste all below into the
shell):

        zsh
        { sleep 60 ; touch /tmp/mytst } &
        disown %1
        exit
        ls -al /tmp/mytst
        sleep 61
        ls -al /tmp/mytst

If this works, /tmp/mytst should be created while sleeping - so
exiting the shell doesn't kill the process. But perhaps they kill all
your processes upon logout? Try this:

        zsh
        { sleep 60 ; touch /tmp/mytst } &
        disown %1
        exit
        ls -al /tmp/mytst
        exit
        (log in once more)
        ls -al /tmp/mytst
        (check if the file is updated)

Try to log in twice (i.e. in two windows). In one window, you run top
or ps or something, to scan your processes. Try something like this in
the other window:

        echo <<EOF>tst.c
#include <unistd.c>
int main() {
        if (fork()) return 0;
        sleep(190); /* Something more fancy might be done here */

Quote:}

EOF
        gcc tst.c
        ./a.out
        # Check if process a.out still is running      
        exit
        (Check in the other window if a.out still is running)
        (exit the other window and log in once more)

And, once more, if you are running at a (more or less) public server,
and you start CPU-eaters without running them at the lowest priority,
you should expect them to be removed by the sysadmin (if there are
more admins or evil admins or they have scripts killing background
processes, they might seem unaware of it).

--
TobiX                   In a world without fences, who needs gates?
http://www.td.org.uit.no/~tobias/