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.

1
vote
0answers
18 views

Regain ability to use ^C to close backgrounded then (effectively) foregrounded processes

In the interactive console, pressing ^C on zenity --info & fg closes the Zenity window. One can only use zenity --info & wait in a script. But ^C doesn't close the Zenity window in this case. ...
0
votes
1answer
271 views

Stop tailing log [on hold]

I have a problem, I accidentally did tail -f on a log, but now I cant quit! - Its the anaconda log during a redhat install. Control-C doesn't seem to work, I guess due to it saying sh: no job control ...
5
votes
2answers
1k views

Why jobs aren't killed at logout when executed with “> /dev/null 2>&1 &”?

When you run jobs like the example below, they're killed when you logout: $ ./job.sh & However, when you execute them as in the below example, redirecting stdout to /dev/null and stderr to ...
1
vote
0answers
20 views

Why does my job control fail inside a loop? [duplicate]

My bash script is supposed to start a process (let's say, run less) and bring it back to foreground every time the process is suspended (e.g. by pressing CTRL-Z). If I just keep repeating the ...
1
vote
1answer
27 views

Output of a command going in background on Mac

I have an issue on my Mac. HQSML-1584960:puppet rmoham860$ git diff [2]+ Stopped git diff HQSML-1584960:puppet rmoham860$ jobs -l [1]- 37022 Stopped (tty output): 22git diff [2]+ ...
15
votes
2answers
13k 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 ...
6
votes
4answers
371 views

Run command in background with foreground terminal access

I am trying to create a function that can run an arbitrary command, interact with the child process (specifics omitted), and then wait for it to exit. If successful, typing run <command> will ...
1
vote
1answer
44 views

Does a shell which does not support job control has the concept of foreground and background processes?

I used to think that only if a shell supports job control, can it has the concept of "foreground" and "background" processes (group). But I read a paragraph indicating that's not true. From APUE § 10....
1
vote
0answers
29 views

List all jobs in all shell sessions (not just the current shell), by current user

I know that the jobs command only shows jobs running in current shell session. Is there a bash code that will show jobs across shell sessions (for example, jobs from another terminal tab) for ...
3
votes
2answers
46 views

How to wrap a command such that its execution is throttled (that is, it executes at most once every X minutes)

I'm interested in wrapping a command such that it only runs at most once every X duration; essentially, the same functionality as the lodash throttle function. I'd basically like to be able to run ...
3
votes
1answer
45 views

Can I make a process become a job of a bash process?

Given an interactive bash process and a process which wasn't started from the bash process, is there some way (program) which can make the process a job of the shell? This may sound impossible, but ...
1
vote
1answer
23 views

Behavior of directly vs indirectly backgrounded children on read

When I do ( sleep 1; read x ; echo x=$x; echo done ) & then with the default terminal settings, the job gets stopped by SIGTTIN. If I do ( ( sleep 1; read x ; echo x=$x; echo done ) & ) ...
3
votes
4answers
6k 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:...
2
votes
1answer
449 views

mpd daemon prematurely ending jobs

I am trying to configure mpirun and mpiexec to run software called Materials Studio on a 1 node, 2 processor, 12 core cluster. The submission scheme is PBS. I had everything set up properly (with some ...
8
votes
3answers
1k views

Why can't I see the “wget” job when I execute it in the background?

I use wget command in the background like this wget -bq and it prints Continuing in background, pid 31754. But when I type the command jobs, I don't see my job(although the downloading is not ...
-2
votes
2answers
49 views

Does an interactive bash process implicitly send any signal other than SIGHUP to its job?

Does an interactive bash process implicitly send any signal other than SIGHUP to its job? By implicitly, I mean not as a consequence of a user's request to send a signal to a job. It helps to answer ...
3
votes
1answer
73 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
0answers
60 views

Program start from interactive shell fails when shell script initiated by launcher

[This post has been edited from the original text to add the results of further investigation and get to the point more quickly -- Thanks @ctrl-alt-delor] Why does this script: #!/bin/bash read -p "...
12
votes
5answers
844 views

How to plan a task to run after another already running task in bash? [duplicate]

I'm looking for something like command1 ; command2 i.e. how to run command2 after command1 but I'd like to plan execution of command2 when command1 is already running. It can be solved by just typing ...
1
vote
0answers
40 views

Killing a process when some other process is finished

Given a | b, i'd like to kill b when a is finished. b is an interactive process, which doesn't terminates when a is finished (fzf in my case), and the whole a | b is executed in a $() subshell. So ...
0
votes
1answer
34 views

cron doesn't execute scripts after setting it up

According to this site I set up cron to execute a script for me, first just trying to get it to work with cat before doing the actual work I need to do (actual work will need root priviliges so I did ...
157
votes
5answers
355k 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 ...
1
vote
2answers
308 views

Is it possible to disconnect a GUI program launched within vifm from vifm?

One can launch GUI programs, for example, gv or xpdf from vifm in background in vifm's command line: :!gv %f & However, if gv is launched by pressing Enter on a file like aPSfile.ps in vifm, it ...
5
votes
2answers
162 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, ...
0
votes
1answer
67 views

Bash interactive shell hangs when Tmux is suspended if it was automatically started by Bash startup file

When I manually start Tmux by issuing tmux from my Bash interactive shell I can later suspend Tmux with CTRL-BZ without problems. Pressing this key combination brings me back to the parent process, i....
-1
votes
1answer
53 views

How can I see the processes structured by sessions and process groups?

As far as I know, linux kenerl has sessions and process groups concept, I want to see the sessions and groups, what should I do?
0
votes
2answers
168 views

How can I run multiple pv commands in parallel?

I want to run a sequence of command pipelines with pv on each one. Here's an example: for p in 1 2 3 do cat /dev/zero | pv -N $p | dd of=/dev/null & done The actual commands in the pipe don't ...
7
votes
1answer
284 views

Stopped (ctrl z) process will not restart, and no longer in job list

I was running apt upgrade, when I needed the terminal, so did a ctrlz. When I tried to restart it (fg), it would not restart, because it was no-longer in the jobs list (jobs). (I Did not, run disown). ...
536
votes
3answers
215k views

Difference between nohup, disown and &

What are the differences between $ nohup foo and $ foo & and $ foo & $ disown
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 ...
1
vote
1answer
364 views

Can't terminate / suspend a background job

I wanted to do a test for the Job Control Commands. So, I ran a cat command and then made it a background job using the bgcommand after stopping it with Ctrl +Z. Now I wanted to first terminate ...
-4
votes
1answer
54 views

Does `wd:` in `jobs` show the current working directory of each job, or the previous working directory when invoking each job?

Does wd: in jobs show the current working directory of each job, or the previous working directory when invoking each job? Can you demonstrate it or quote from some references? I was under the ...
0
votes
1answer
72 views

How can I bring a background GUI job to the front of my desktop?

In Lubuntu 18.04, I have many background GUI jobs running in a bash shell. Among them, I have a evince process running in background: $ jobs | grep evince [29] Running evince ...
2
votes
1answer
378 views

How to stop ./configure script?

I need to remotely install a program on a Linux computer. I do: ./configure make make install However I seem to get issues when I run ./configure (it's a separate problem) where the configuration ...
1
vote
2answers
462 views

How to control a backgrounded subshell?

If I run the following command at a bash prompt: (for i in {1..100}; do echo $i; sleep 1; done) & It will start counting and immediately return me to my prompt. I can continue working normally, ...
0
votes
0answers
455 views

Shell: send foreground process to background without suspending it? [duplicate]

I have a command I'm running in the background, fnordctl & Occasionally I pull it up into the foreground, fg Now, I'd like to send it back to the background to continue running. Typing Ctrl-z ...
2
votes
1answer
120 views

How to start Vim from a trap and still be able to resume it after suspending it?

I have the following code in my ~/.zshrc: nv() ( if vim --serverlist | grep -q VIM; then if [[ $# -eq 0 ]]; then vim elif [[ $1 == -b ]]; then shift 1 IFS=' ' vim --...
0
votes
1answer
49 views

Monitor Process Output For Scripts

Is there a way to view the console outputs of a particular script that is running in the background on a machine? Maybe using the pid or something similar. For example, to view the output of this ...
2
votes
1answer
92 views

How does bash's job control handle stopped or terminated background jobs?

While studying the internals of bash's job control mechanism under Linux I have came across a little problem of understanding. Let's assume the following scenario: script is executed in background ...
10
votes
1answer
164 views

How can I cancel the rest of a list of commands in Bash?

In Bash, occasionally I will type in a list of commands and hit Enter, and only later realize that there is a mistake with some command near the end of the list. I know that if I press Ctrl+C it will ...
1
vote
1answer
46 views

Killing jobs started within functions

I'm trying to use some functions in a bash script to simplify calling some child processes. I want to decide at the call site whether or not to run the process in the background as a job, or in the ...
43
votes
4answers
33k views
0
votes
3answers
132 views

Get process information (the command, etc) from pid

I have this code: for job in `jobs -p`; do code=0; wait ${job} || code=$? if [[ "${code}" != "0" ]]; then echo "At least one job failed with exit code =>...
5
votes
2answers
2k 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 ...
33
votes
7answers
31k 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 ...
3
votes
0answers
30 views

Log background jobs started in all the manually started shells?

Sometimes I accidentally killed all the background jobs in a shell, for example, because The window of a Window's program running under Wine is not in the front by default. I know I can use ...
3
votes
1answer
69 views

Assign job number to background process by hand

Let's say I send two jobs to the background. $ sleep 77 & $ sleep 99 & Then I check my jobs $ jobs > [1] - running sleep 77 > [2] + running sleep 99 Can I control what job ...
0
votes
1answer
280 views

Is the “kill” command for job control the same as the “kill” command to send a signal to a process?

In Linux, you can do the following: kill 1 (or kill %1) Which means "close the processes in job number 1". And you can do the following: kill 1234 Which means "send the SIGTERM signal to the ...
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 ...
156
votes
9answers
105k 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, ...