UNIX/Linux background job

crazydave

Senior member
Apr 18, 2000
251
0
0
Hey guys,

I'm sure I knew this at some point, but I don't seem to remember at the moment...

How do you start a process in UNIX or Linux and keep it running even after you logout (say I'm logging in using Telnet or SSH). In other words, I want to daemonize a process (is that the right word for this situation?). Basically I can do something like this:

$ myprogram&

to run it in the background, but that's only good while the current session's running....I want to keep it running after I logout. Thanks a lot.
 

Syran

Golden Member
Dec 4, 2000
1,493
0
76
When I used to run a mud back in the mid-90's, the "space &" always worked for keeping the process in background, even when I logged off the server (the mud was hosted externally, so I'd have to telnet to restart it if it crashed).

One note thou, it did have a ./start command that called the ./startup & command...
 

Fallen Kell

Diamond Member
Oct 9, 1999
6,194
528
126
Ok, to the differences between nohup, and screen... Use screen whenever it is a process that you want to bring back to the console (or xwindow) when you connect back up. Basically things like matlab, or other intense programs that can take hours to run and use a xwindow to display information about it. You might also run a compile through screen. I remember XFree86 taking 8 hours to compile... and log out and log back in later on, connect back up to the screened process and get the info back. Screen is also useful to use on another networked system. That way you can log in from just about anywhere and connect back up to that process.

Nohup is used to promarily run a process that you do not need to monitor directly (it logs itself or you just don't care).
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Fallen Kell
Nohup is used to promarily run a process that you do not need to monitor directly (it logs itself or you just don't care).

you can still monitor it, it outputs to nohup.out.
 

Hector13

Golden Member
Apr 4, 2000
1,694
0
0
Originally posted by: BingBongWongFooey
Originally posted by: Fallen Kell
Nohup is used to promarily run a process that you do not need to monitor directly (it logs itself or you just don't care).

you can still monitor it, it outputs to nohup.out.

or just redirect any output to a log file of your choice (and watch it with a "tail -f" if necessary)