Home Linux Community Forums Software Command Line Running processes in the background

Running processes in the background

Link to this post 24 May 09


I know how to run a process in the background:

bigprocess &

Now I get the pid of the process.

After a while I want to view the output of the program.

How can I do that?

Furthermore, how can I send an open process to the background?

Thank you.


Link to this post 25 May 09


if I run a job in background here I still see the output in the terminal...
you can store the output in a file and check that file later like

./ > output.txt &

but I guess you know that.

A running job can be stopped with CTRL+z. If you type

it continues execution in background. With
you can reattach it if you want.

Have you tried screen already?
With this tool you can start the big job and even close the terminal (or close the connection if it is a remote host) and later reattach it.
This would work something like that

screen -d -m

to reattach:

screen -d -r

with CTRL+a CTRL+d you can detach again.

Perhaps it helps...

Link to this post 25 May 09

If you invoke the background process from a window terminal like "xterm" like this

#> program&

It's fine, but since the "program" is a child from the terminal process if you accidentely close the terminal you also kill the "program", so you can also use nohup to avoid closing the background process:

#> nohup program&

This way the "program" or background process doesnt "hang up" after closing his parent terminal.


Link to this post 25 May 09

Thank you, guys.

The screen thing looks very nice. I'll try it later.


Link to this post 27 May 09

Another cool tool is dtach, you can direct the output to a socket and attach to it as you want (runs like a daemon).

dtach -n /tmp/myprog /usr/bin/myprog

to attach again:

dtach -a /tmp/myprog

Link to this post 30 Apr 10

When I want to run the process in to backgroud, I use the & at the end of command. I bring the background process back with bg and fg command. :) .

I try to build the article about linux command line in thai language at .


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Linux Training / Board

/** BC-056 Ameex changes to add tracking code - 2016-01-22 **/ ?>