Questions tagged [job-control]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
25 views

Background process in a shell script?

I wanted to find a way to run Spock tests in headless mode. One solution I found involves running these two commands: Xvfb :99 &>/dev/null & export DISPLAY=:99 This works. I am not sure ...
0
votes
1answer
32 views

How does bash `auto_resume` job control variable works?

Chapter 7.3 Job Control Variables in Bash Reference Manual has the following description about auto_resume variable: auto_resume This variable controls how the shell interacts with the user ...
0
votes
0answers
24 views

Alias problems with inline job control [duplicate]

I am having a problem with the following: Alias: alias gks='gitk --all &; clear; git status'   When I try it I see - Console Resp: $ gks bash: syntax error near unexpected token `;' ...
1
vote
2answers
35 views

How to ensure child background processes terminate when using `set -e`?

set -e while true; do echo "test"; sleep 1; done & echo "done" ueoa If I run this, once it reaches ueoa (a random command that does not exist), it'll 'terminate' but keep the while true; do ...
0
votes
0answers
58 views

/usr/bin/fg: line 4: fg: no job control

I have faced the problem mentioned above when I call sleep 100 & Background job starts, and then I pause the process by: kill -STOP <PID> Then if I just say fg sleep It brings the job ...
1
vote
1answer
46 views

Given a job’s pid, bring the paused job to background/foreground and running state

I am working on my own shell and I have a confusion about job management. I am able to list processes owned by a user and pause any process that its pid is given. However, as stated in title, I need ...
1
vote
0answers
14 views

Systems trigger when CPU usage is low

Background There is a server that is used to run simulations that I was just invited to. Unfortunately, instead of some reasonable job manager (i.e., slurm) they have a system where only one big job ...
1
vote
1answer
85 views

How to kill all background jobs in dash?

Simply kill $( jobs -p ) not work in dash. For example in dash: $ sleep 999 & $ kill $(jobs -p) dash: 2: kill: Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or kill -l [...
4
votes
2answers
73 views

how can I run a command from an environment variable and have the internal trailing ampersand work?

I have this small script I call prompt-to-run. prompt_acc='' read -p 'run `'"$1"'` ' -i "$1" -e prompt_acc $prompt_acc It lets me create a script that fills in a command for me, but gives me the ...
1
vote
3answers
67 views

Option to cancel job by jobname not ID?

Is it possible to delete multiple jobs with the same name, instead of typing in each individual job number? I do not want to use the qdel -u username option, as I have other jobs that I want to ...
2
votes
0answers
37 views

Key binding to swap shell foreground/background jobs

In spite of heavy tmux use and switching between panes, I still frequently find myself using shell job control. When something needs poking I'll background the tool I'm using with Ctrl+Z, poke the ...
1
vote
1answer
82 views

Show progress of a for loop after it was started

I started a for loop in an interactive bash session. For this question we can assume the loop was something like for i in dir/*; do program "$i" done > log The command takes a lot longer than ...
0
votes
1answer
47 views

Need an “at” Command Timestamp That Runs Command Monthly at Given Day

Need an at command timestamp that run some command at given day monthly, like for example, every day 15, as would follow: $ at every 15 day So that on every day 15, it would run some command. How ...
0
votes
0answers
26 views

Is SIGHUP sent to an orphaned process group without stopped jobs?

The GNU libc manual claims that: When a process group becomes an orphan, its processes are sent a SIGHUP signal. Ordinarily, this causes the processes to terminate. However, if a program ignores ...
1
vote
0answers
1k views

Killing a process running executed with sudo without using sudo in kill command

So I have a server, and I have access to sudo to do one thing only: run a single whitelisted script (I'll call it the target script). I do not have access to sudo anything else. Problem is, this ...
1
vote
0answers
139 views

Bash: kill process and all subprocesses without using group id

TL;DR, I need a way to kill a process and all descendant processes, without killing siblings with the same group id, without output printed in the terminal, and with a non-zero exit code. I have a ...
0
votes
1answer
46 views

Subshell Job Clarification

I run the command (Xorg & sleep 3; xeyes) & to test Xorg, and group it into a single subshell background job to make management easy. This works properly, and opens xeyes in the new Xorg ...
2
votes
0answers
75 views

Is job-control really meant to be supported in subshells and scripts?

Small premise I use subshells quite often to perform operations that involve changing the Shell Execution Environment, so as not to affect the main shell. I do it often from an interactive shell, and ...
1
vote
1answer
65 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
38 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
950 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
122 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. ...
1
vote
0answers
23 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
97 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]+ ...
1
vote
1answer
74 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....
2
votes
0answers
359 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 ...
6
votes
4answers
2k 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 ...
3
votes
2answers
56 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
55 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
32 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 ) & ) ...
8
votes
4answers
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
56 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
133 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
158 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
4k 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
131 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
47 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 ...
5
votes
2answers
271 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
209 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
76 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
570 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 ...
-4
votes
1answer
97 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
2answers
322 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 ...
0
votes
0answers
1k 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
236 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
109 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
275 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 ...
7
votes
1answer
468 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). ...
10
votes
1answer
202 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
61 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 ...