Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [job-control]

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

156
votes
9answers
107k views

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, ...
550
votes
3answers
223k views

Difference between nohup, disown and &

What are the differences between $ nohup foo and $ foo & and $ foo & $ disown
139
votes
2answers
166k views

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 ...
7
votes
1answer
2k views

Difference between process group and job?

What's the difference between a process group and a job? If I type pr * | lpr then is it both a process group as well a job? What exactly is the difference between a process group ID and a job ID? ...
45
votes
4answers
34k views

What is the difference between a job and a process?

What is the difference between a "job" and a "process"?
34
votes
7answers
32k views

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 ...
25
votes
4answers
9k views

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 ...
5
votes
2answers
169 views

Process killed before being launched in background

I'm using a bash script script.sh containing a command cmd, launched in background: #!/bin/bash … cmd & … If I open a terminal emulator and run script.sh, cmd is properly executed in background, ...
160
votes
5answers
365k views

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 <jobid>. I wonder how to suspend a process running in the ...
17
votes
2answers
5k views

Concept of controlling terminal in Unix

Can some one please explain in an easy to understand way the concept of controlling terminal in unix and unix like systems ? Is it related to a session ? If yes, then how ?
19
votes
1answer
34k views

How to recover a backgrounded job from a previous shell? [duplicate]

Possible Duplicate: How can I disown a running process and associate it to a new screen shell? I launched a command that lasts a long time. I had to disconnect so I moved it in the background (...
1
vote
2answers
2k views

Basic job control: stop a job, add a job onto the stack, and `fg`

Job control is probably my favorite thing about Linux. I find myself, often, starting a computationally demanding process that basically renders a computer unusable for up to days at a time, and being ...
10
votes
1answer
7k views

Why do backgrounded processes sometimes stop spontaneously?

Sometimes, some time after I've backgrounded a process with bg in bash, when I press Enter in the same shell to redisplay the prompt (just to check that I'm still in bash when some output from the ...
10
votes
3answers
3k views

Get PID of any command in backgrounded piped sequence of commands

If, in bash, I execute: cmd1 | cmd2 | ... | cmdi | ... | cmdn & where the cmd{1..n} may not be distinct, how do I get the PID of cmdi? Alternatively, how can I signal the cmdi process? (For ...
5
votes
2answers
3k views

Is there any way to exit “less” follow mode without stopping other processes in pipe?

Often times I find myself in need to have the output in a buffer with all the features (scrolling, searching, shortcuts, ...) and I have grown accustomed to less. However, most of the commands I use ...
9
votes
1answer
15k views

Non-blocking bash command

Let's say I have a bash script with the following: #!/bin/sh gedit rm *.temp When I execute it using sh ./test.sh, gedit pops-up but the rm part does not run until after I close gedit. I want the ...
4
votes
1answer
293 views

What is the purpose of abstractions, session, session leader and process groups?

I understand from Informit article that sessions and process groups are used to terminate descendant processes on exit and send signals to related processes with job control. I believe this ...
3
votes
1answer
92 views

Does ` (sleep 123 &)` remove the process group from bash's job control?

Does the following way $ (sleep 123 &) $ jobs $ remove the process group of sleep 123 from bash's job control? What is the difference between the above way and disown then? Note that the sleep ...
1
vote
2answers
499 views

What is the real-world use of the bg command?

This is the output: [USER@SERVER ~] ping localhost PING localhost (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.037 ms 64 bytes from localhost (127....
28
votes
3answers
2k views

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? ...
13
votes
1answer
11k views

How to suspend and resume processes like bash does

this question is a follow-up to: How to suspend and resume processes I have started firefox from a bash session in gnome-terminal. The process tree looks like this: $ ps -e -o pid,ppid,cmd -H 1828 ...
15
votes
1answer
48k views

Start a background process from a script and manage it when the script ends

I'd like to run and configure a process similarly to a daemon from a script. My shell is zsh emulated under Cygwin and the daemon is SFK, a basic FTP server. For what matters here, the script ...
6
votes
2answers
2k views

Is it possible to transfer a running process to your terminal? [duplicate]

Possible Duplicate: How can I pause up a running process over ssh, disown it, associate it to a new screen shell and unpause it? It is fairly easy to disown a process, or make it run without a ...
3
votes
4answers
7k views

How to kill all jobs in bash?

So, I have some jobs like this: sleep 30 | sleep 30 & The natural way to think would be: kill `jobs -p` But that kills only the first sleep but not the second. Doing this kills both processes:...
15
votes
2answers
14k views

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 ...
13
votes
2answers
8k views

Change the parent process of a process?

Is it possible to change the parent process of a process? If yes, how? For example, how does screen manage to attach a screen session and the processes running inside it to different shell ...
8
votes
2answers
48k views

What is “Exit 2” from finished background job status?

I have an exercise to put in a file some data (*conf from some directories) and need to do this in background. I did it and I am wondering what is the meaning of output messages: [A@localhost tests]$ ...
5
votes
1answer
593 views

Why is subshell created by background control operator (&) not displayed under pstree

I understand that when I run exit it terminates my current shell because exit command run in the same shell. I also understand that when I run exit & then original shell will not terminate because ...
1
vote
1answer
2k views

What does “fg” stand for?

There is no manual entry for ctrl-z or fg. What does "fg" stand for in the context of job control? In other words, typing ctrl-z will suspend the current job drop me back into the shell, and the ...
9
votes
4answers
8k views

disabling job control in bash (CTRL-Z)

It happens to me sometimes, that I press CTRL+Z by accident and my application disappears into background. I know, I can bring it back with fg, so it's not such a big deal. But I am wondering about ...
5
votes
3answers
4k views

How to run multiple background jobs in linux?

I have a basic understanding of how to get a job in foreground switch to background and vice-versa but I am trying to come up with a way so that I can run multiple jobs in the background.I tried to ...
3
votes
1answer
478 views

Background task finished notification syntax

Last night, before abandoning my computer for the evening, I started a bunch of compiler jobs so they'd be ready in the morning, using make -f alpha.mak &>alpha.out &. When I came back and ...
2
votes
3answers
2k views

Queue a task in a running shell

I often start a long running command that is bound to either CPU, Disk, RAM or Internet connection. While that is running, I find that I want to run a similar command. Let's say downloading something ...