-   Linux - Software (
-   -   leave process running after logoff (

nakkaya 10-27-2003 03:00 AM

leave process running after logoff
i have a machine without a monitor so i use ssh to control it but how can i leave a program running after i log off..

coolamit78 10-27-2003 06:28 AM

To keep a program running while not logged on, you need to use the prefix your command with the word nohup. You will need to run this command in the background.

for example:

$ nohup grep 'director' emp.lst & | nohup sort &

The above command will search the file 'emp.lst' for the word 'director' and then the entire output from the first command is sent to the 'sort' command which arranges the results in ASCII sequence. Note the use of ampersand sign (&), which keeps the job running in the background.



hw-tph 10-27-2003 07:26 AM

Use screen. I love it, it's very versatile and pretty simple to use.
Example: I use the pftp-mew FTP client. If I want to download something to my home computer from school or work I just SSH to my home box, type screen pftp to launch a screen session running pftp. I start up a download and then press Ctrl+A and then Ctrl+D to disconnect from the screen. You will be returned to your shell. Log off if you want to. Later on you can log in and reconnect to the screen session using screen -r to see how your download is progressing.

You can also type screen without any parameters. This will launch a screen session running bash (if that's your default shell). Start compiling or whatever you want, then again use Ctrl+A, Ctrl+D to detach from the session. I use this frequently (all the time actually) to run my Enemy Territory server. It works with pretty much any console application and it's darn handy. You can have several sessions going on at the same time, divided into different "windows" (I don't recall the correct term at the moment, sorry).
Start a new screen session, and then type Ctrl+A, Ctrl+C to create a new window. You can run anything here (as usual), then type Ctrl+A, Ctrl+C again to create a third window. You can now run three programs at the same time and switch between the different windows using Ctrl+0 (for the first window you created), Ctrl+1 (for the second), Ctrl+2....etc.

Read up on the man page for more info: man screen
If you don't have screen installed you should be able to grab it from your distribution as it's a very common tool.


jhayes 04-07-2004 12:42 PM

thansk for the tip hw-tph but that didn't work for my purposes. It kind of behaves like &. Somehow my app only works when being started from the console.


deloptes 04-09-2004 02:21 AM

I think there was somthing like log out with CTRL+D and than sending ~ to the terminal...

All times are GMT -5. The time now is 08:14 PM.