A 'background' process is a computer process that runs "behind the scenes" (i.e. in the background) and without user intervention. Typical tasks for using such processes include logging, system monitoring, scheduling, and user notification. Use this tag for any questions about background processes.
Questions tagged [background-process]
620 questions
451
votes
11 answers
How can I run a command which will survive terminal close?
Sometimes I want to start a process and forget about it. If I start it from the command line, like this:
redshift
I can't close the terminal, or it will kill the process. Can I run a command in such a way that I can close the terminal without…
Matthew
- 5,417
- 4
- 19
- 11
336
votes
4 answers
How to get the pid of the last executed command in shell script?
I want to have a shell script like this:
my-app &
echo $my-app-pid
But I do not know how the get the pid of the just executed command.
I know I can just use the jobs -p my-app command to grep the pid. But if I want to execute the shell multiple…
David S.
- 5,529
- 5
- 30
- 39
331
votes
12 answers
How to terminate a background process?
I have started a wget on remote machine in background using &. Suddenly it stops downloading. I want to terminate its process, then re-run the command. How can I terminate it?
I haven't closed its shell window. But as you know it doesn't stop using…
Mohammad Etemaddar
- 12,227
- 7
- 24
- 35
294
votes
11 answers
Keep processes running after SSH session disconnects
I sometimes have long running processes that I want to kick off before going home, so I create a SSH session to the server to start the process, but then I want to close my laptop and go home and later, after dinner, I want to check on the process…
λ Jonas Gorauskas
- 3,550
- 3
- 20
- 19
265
votes
5 answers
How to suspend and bring a background process to foreground
I have a process originally running in the foreground. I suspended by Ctrl+Z, and then resume its running in the background by bg .
I wonder how to suspend a process running in the background?
How can I bring a background process to…
Tim
- 98,580
- 191
- 570
- 977
164
votes
3 answers
If you ^Z from a process, it gets "stopped". How do you switch back in?
I accidentally "stopped" my telnet process. Now I can neither "switch back" into it, nor can I kill it (it won't respond to kill 92929, where 92929 is the processid.)
So, my question is, if you have a stopped process on linux command line, how do…
bobobobo
- 1,765
- 2
- 11
- 6
162
votes
9 answers
Run a command without making me wait
On the CLI, sometimes a command I type takes a while to complete, and sometimes I know when that's about to happen. I'm a bit confused on "backgrounding" and such in Linux.
What is the most common (or user-friendly way) of telling the CLI that I…
themirror
- 6,898
- 11
- 31
- 36
113
votes
7 answers
How to kill SSH session that was started with the -f option (run in background)
I'm pretty lost on this. From the man page:
-f Requests ssh to go to background just before command execution.
After starting SSH with the -f option, I have a working tunnel. But after I finish using it I don't know how to further interaction…
MountainX
- 17,168
- 59
- 155
- 264
104
votes
10 answers
How to do nothing forever in an elegant way?
I have a program which produces useful information on stdout but also reads from stdin. I want to redirect its standard output to a file without providing anything on standard input. So far, so good: I can do:
program > output
and don't do anything…
a3nm
- 8,978
- 5
- 28
- 36
86
votes
5 answers
Run multiple commands and kill them as one in bash
I want to run multiple commands (processes) on a single shell. All of them have own continuous output and don't stop. Running them in the background breaks Ctrl-C. I would like to run them as a single process (subshell, maybe?) to be able to stop…
user1876909
- 962
- 1
- 6
- 9
61
votes
7 answers
Execute remote commands, completely detaching from the ssh connection
I have 2 computers, localpc and remoteserver.
I need localpc to execute some commands on remoteserver. One of the things it needs to do is start a backup script that runs for a number of hours. I would like the command on localpc to “fire” and then…
LVLAaron
- 1,715
- 8
- 28
- 31
53
votes
4 answers
What's the difference between running a program as a daemon and forking it into background with '&'?
What are the practical differences from a sysadmin point of view when deploying services on a unix based system?
user1561108
- 1,041
- 2
- 14
- 26
50
votes
3 answers
Permanent background ssh connection to create reverse tunnel: what is correct way?
Related question: initiate ssh connection from server to client
Answer from there helped me a lot, this command does what I need:
ssh -R 2225:localhost:22 loginOfServerWithPublicIP@publicIP
So I wrote the script to reconnect all the time:
…
Dmitry Frank
- 2,668
- 8
- 27
- 38
50
votes
1 answer
GNU parallel vs & (I mean background) vs xargs -P
I'm confused about the difference or advantage (if any) of running a set of tasks in a .sh script using GNU parallel
E.g. Ole Tange's answer:
parallel ./pngout -s0 {} R{} ::: *.png
rather than say looping through them putting them in the background…
Stephen Henderson
- 979
- 3
- 10
- 16
42
votes
5 answers
I am using `&`: why isn't the process running in the background?
I know that I can append & to a command to run the process in the background.
I'm SSH'ing into an Ubuntu 12.04 box and running a python program with $python program.py & -- but when I go to close the terminal window I get a message saying that…
bernie2436
- 6,505
- 22
- 58
- 69