Questions tagged [job-control]

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

1
vote
1answer
47 views

How to start a job, do something different, and resume it again

I want to start a web server via Python. When this succeeds, I want to open the page in the default browser (on macOS, you can do this with the open command), and after that, I want to resume the ...
1
vote
2answers
30 views

What's the best way to run a long script without the SSH client crashing?

I'm on OpenSUSE 12.1, so no tmux, and we're not allowed to install anything - wget is too old to download a binary as well. Often I and other users have to run long scripts that take several hours, ...
4
votes
4answers
174 views

Command for “wait for the job to finish and then begin another job”? [duplicate]

Without knowing ahead of time that I'll want to do this, is it possible to wait for a job to finish and automatically begin executing another one? For example, I jump into a tmux session and execute ...
3
votes
2answers
94 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
277 views

Stop tailing log [closed]

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
35 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
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 ...
6
votes
4answers
649 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
48 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
37 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
47 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
47 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
25 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
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:...
2
votes
1answer
454 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
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
0answers
83 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
1k 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
44 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
39 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 ...
160
votes
5answers
366k 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
318 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
170 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
91 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
58 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
263 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
314 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). ...
550
votes
3answers
223k 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
391 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
63 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
87 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
414 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 ...
2
votes
2answers
504 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
580 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
139 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
57 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
114 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
170 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
51 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 ...
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"?
0
votes
3answers
140 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
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 ...
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 ...
2
votes
0answers
31 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
71 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 ...