Questions tagged [job-control]

Questions about the various ways jobs can be controlled by the shell: suspending, resuming, terminating execution etc.

223 questions
772
votes
5 answers

Difference between nohup, disown and &

What are the differences between $ nohup foo and $ foo & and $ foo & $ disown
Lesmana
  • 26,889
  • 20
  • 81
  • 86
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…
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
199
votes
2 answers

How to suspend and resume processes

In the bash terminal I can hit Control+Z to suspend any running process... then I can type fg to resume the process. Is it possible to suspend a process if I only have it's PID? And if so, what command should I use? I'm looking for something…
Stefan
  • 24,830
  • 40
  • 98
  • 126
191
votes
9 answers

How can I disown a running process and associate it to a new screen shell?

I have a running program on a SSH shell. I want to pause it and be able to unpause its execution when I come back. One way I thought of doing that was to transfer its ownership to a screen shell, thus keeping it running in there. Is there a…
levesque
  • 3,775
  • 5
  • 20
  • 15
65
votes
4 answers

What is the difference between a job and a process?

What is the difference between a "job" and a "process"?
Olivier Lalonde
  • 5,149
  • 5
  • 24
  • 20
38
votes
7 answers

How can I close a terminal without killing its children (without running `screen` first)?

sometimes I run an app in the gnome-terminal, but then I suddenly have to restart gnome or something. I guess the answer to the question is also useful then I want to disconnect from SSH where something is happenning. Gnome's terminal tree looks…
valya
  • 635
  • 1
  • 6
  • 11
35
votes
2 answers

Can someone explain in detail what "set -m" does?

On the man page, it just says: -m Job control is enabled. But what does this actually mean? I came across this command in a SO question, I have the same problem as OP, which is "fabric cannot start tomcat". And set -m solved this. The OP…
laike9m
  • 593
  • 1
  • 5
  • 7
34
votes
4 answers

What is the purpose of delayed suspend (Ctrl-Y) in Bash?

The full portion of the Bash man page which is applicable only says: If the operating system on which bash is running supports job control, bash contains facilities to use it. Typing the suspend character (typically ^Z, Control-Z) while …
Wildcard
  • 35,316
  • 26
  • 130
  • 258
33
votes
1 answer

ctrl c vs. ctrl z with foreground job

Ctrl+Z stops the job whereas Ctrl+C kills the job. Why is that? Wouldn't the other way make more sense? z@z-lap:~$ sleep 100& [1] 4458 z@z-lap:~$ sleep 200& [2] 4459 z@z-lap:~$ jobs [1]- Running sleep 100 & [2]+ Running …
neo0
  • 755
  • 2
  • 7
  • 7
31
votes
3 answers

Do programs run from an ssh session depend on the connection?

Does a program that is run from an ssh session depend on the connection to the client? For example when the connection is really slow. So does it actively wait until things are printed on the screen? And if it does depend on the connection, does it…
agold
  • 533
  • 5
  • 12
28
votes
2 answers

Why does "yes&" crash my Bash session?

"Yes, and..." is a wonderful rule-of-thumb in improvisational comedy. Not so much in the UNIX world. When I run the admittedly silly yes& command, I cannot interrupt it. The terminal crashes or gets stuck into a loop. I expect the yes process to be…
Sebastian Carlos
  • 146
  • 2
  • 12
28
votes
5 answers

How can I kill and wait for background processes to finish in a shell script when I Ctrl+C it?

I'm trying to set up a shell script so that it runs background processes, and when I Ctrlc the shell script, it kills the children, then exits. The best that I've managed to come up with is this. It appears that the kill 0 -INT also kills the script…
slipheed
  • 391
  • 1
  • 3
  • 5
28
votes
4 answers

What happens to the output of a process that has been disowned and lost its terminal?

If I close the virtual terminal, where some process was started, does the output just go straight to /dev/null, or can it pollute memory somehow? Can I anyhow grab the output to continue reading it at any point after that? [EDIT]: So, is the moment…
rozcietrzewiacz
  • 38,754
  • 9
  • 94
  • 102
27
votes
3 answers

How can I prevent the second command in a chain while keeping the first one running?

Yesterday before going to sleep I started a long process of which I thought it would be finished before I stand up, therefore I used ./command && sudo poweroff my system is configured to not ask for a password for sudo poweroff, so it should…
Max Matti
  • 493
  • 6
  • 13
1
2 3
14 15