"right" way to keep a process running after logout?

"right" way to keep a process running after logout?

Post by Glen Coate » Sun, 01 Dec 2002 15:14:54



I'd like to know the best way to keep a process going after you've logged
out.  Specifically, I'm trying to start 'ncftpget' processes while logged
into an RH box via ssh, then logout and let the download happen while I'm
away.

At the moment I'm just C-z'ing the ncftpget process, then hitting C-d to
logout.  If I do this, the session won't close by itself (ie I am not
returned to the shell on the local machine) so I have to hard-kill the
terminal window.  Also, when I re-login to the RH box I find that when the
download finishes the process becomes defunct (presumably because the
terminal it was attached to is gone).

Is there a cleaner way I could be doing this?

--
Cheers,
Glen

 
 
 

"right" way to keep a process running after logout?

Post by Michael Lee Yoh » Sun, 01 Dec 2002 15:36:31


Quote:> Is there a cleaner way I could be doing this?

You can either run "screen" and detach the terminal (leaving a socket file
in a temporary directory) with the running process of ncftpget OR utilize
the "nohup" command.

See the man pages for each to see their functions.

--


QUIPd 1.03: (157 of 953)
-> Is it extreme to want the government to abide by the
-> Constitution? To believe that the Bill of Rights
-> should be honored literally?
-> - Harry Browne

 
 
 

"right" way to keep a process running after logout?

Post by CrayzeeWul » Sun, 01 Dec 2002 19:01:46



> I'd like to know the best way to keep a process going after you've logged
> out.  Specifically, I'm trying to start 'ncftpget' processes while logged
> into an RH box via ssh, then logout and let the download happen while I'm
> away.

> Is there a cleaner way I could be doing this?

Always read the manual first. Look for the "-b" flag in the ncftpget
manual.  

--
CrayzeeWulf

 
 
 

"right" way to keep a process running after logout?

Post by Dave Bro » Mon, 02 Dec 2002 00:28:52




> I'd like to know the best way to keep a process going after you've logged
> out.  Specifically, I'm trying to start 'ncftpget' processes while logged
> into an RH box via ssh, then logout and let the download happen while I'm
> away.

> At the moment I'm just C-z'ing the ncftpget process, then hitting C-d to
> logout.  If I do this, the session won't close by itself (ie I am not
> returned to the shell on the local machine) so I have to hard-kill the
> terminal window.  Also, when I re-login to the RH box I find that when the
> download finishes the process becomes defunct (presumably because the
> terminal it was attached to is gone).

It sounds like you're not running the process in the background.  When
you "C-z", you have stopped the process, but it's not running.  If you
were to type "bg", it would restart in the background.

Or you could start the process in the background with "ncftpget ... &".
The "&" causes the process to disconnect from the terminal, and run in
the background without a terminal.  

Some processes you start thus will still terminate when the initiating
terminal "hangs up"; (they receive a "HUP" signal).  If that's the
case, and you don't want that to happen, you can start the process with
"nohup".

--
Dave Brown  Austin, TX

 
 
 

"right" way to keep a process running after logout?

Post by Ed Blackma » Sun, 01 Dec 2002 20:37:40



> I'd like to know the best way to keep a process going after you've
> logged out.  Specifically, I'm trying to start 'ncftpget' processes
> while logged into an RH box via ssh, then logout and let the
> download happen while I'm away.

If you want to be able to interact with the program later on, possibly
from another location, run 'screen', then run your program in the
subshell it creates.  You can detach from the screen session, log out,
and reattach later (possibly logging in from somewhere else), and your
program will be running like you never left it.  If I'm going to start
editing a file at work, but don't think I'll finish before I want to
go home, I do this so I can go home and continue editing the file,
without losing all of my undo history, etc.

If you know you're going to want to detach and log out, but don't care
about interactivity, start the process with 'nohup'.  For example,
'nohup ncftpget ... &'.

If you didn't think you were going to want to detach it when you
started, but then changed your mind, stop the job with Ctrl-Z, and
resume it in the background with 'bg'.  Then tell your shell not to
send it a HUP signal when you log out.  In bash, you can do this with
the builtin command 'disown -h'.  See the bash manual for details.

Ed

 
 
 

1. "right" way to keep a process running after logout?

Hi,

I'd like to know the best way to keep a process going after you've logged
out.  Specifically, I'm trying to start 'ncftpget' processes while logged
into an RH box via ssh, then logout and let the download happen while I'm
away.

At the moment I'm just C-z'ing the ncftpget process, then hitting C-d to
logout.  If I do this, the session won't close by itself (ie I am not
returned to the shell on the local machine) so I have to hard-kill the
terminal window.  Also, when I re-login to the RH box I find that when the
download finishes the process becomes defunct (presumably because the
terminal it was attached to is gone).

Is there a cleaner way I could be doing this?

--
Cheers,
Glen

2. slip?

3. GETSERVBYNAME()????????????????????"""""""""""""

4. CDE File Menus - how to get rid of/disable Open Terminal

5. A "dbx lite" program for "zapping" a running process?

6. User input to "system" in awk

7. Bizarre "find" process running under owner "nobody"

8. How to build fresco with xfree 3.1 ?

9. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

10. get rit of "lock the desktop" and "logout"

11. Combining NATD with IPFW's "keep-state" and "check-state" rules

12. Type "(", ")" and "{", "}" in X...

13. Background process terminated after logout from "bash"