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
1
vote
0answers
25 views

How to return a value from a job?

I want to spin up some jobs within a script to do some work in parallel. I will know when the work is done by counting the number of active jobs. The issue I'm having is that I want to also return a ...
0
votes
1answer
15 views

How to kill jobs from a script that didn't clean them up

I have a script that started a job but didn't clean it up. The job is running in a loop in the background and I don't know which process it is and it's not listed in jobs. It's printing spam in my ...
27
votes
3answers
2k views

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 ...
1
vote
1answer
66 views

Configure zsh jobs output and fg behavior

Until recently I was pretty satisfied with how the fg and jobs command worked in my zsh, i.e.: just fg -> foreground the most recently backgrounded job again jobs -> display command name (incl. ...
2
votes
1answer
66 views

'jobs' shows a no longer existing process as running

I'm running a long-running pipeline from bash, in the background: find / -size +500M -name '*.txt' -mtime +90 | xargs -n1 gzip -v9 & The 2nd stage of the pipeline takes a long time to complete ...
2
votes
0answers
58 views

How to suspend and resume processes from a script

I am trying to solve the problem given in pause youtube-dl when network is disconnected and resume when it is connected again To stop and resume process, I have taken guideline from How to suspend and ...
-1
votes
1answer
29 views

Does a program run by bash runs in a new job?

In this video, it is said that: In the normal arrangement, if you open a terminal, and inside you have a shell running, that shell represents the start of a new session. That session starts with one ...
1
vote
0answers
39 views

What happens when we put AND-LISTS to background?

I am trying to understand how shell manages process groups of members of AND-LISTS. For example, Bash (and also dash) implements the following behavior: p1 && p2 - processes p1 and p2 have ...
1
vote
0answers
54 views

how to suspend a remote process started by: local-shell -> ssh -> remote bash -> remote-process

I have one, single terminal/channel to a remote system. I can use ssh to open Bash on that system and interact with it to invoke desired remote process. Due to some reason, the remote process is no ...
0
votes
0answers
156 views

Understanding background processes and terminal process group id

I am reading the bash reference manual about Job control found here (emphasis mine): To facilitate the implementation of the user interface to job control, the operating system maintains the notion ...
3
votes
3answers
94 views

Map shell job numbers to PIDs

I use shell job control to kick longer running tasks in to the background so I can continue while they churn through their data. I can see the jobs I've got running with jobs, for example, jobs [2]- ...
1
vote
1answer
35 views

Return to a particular job in the jobs list

If I have the following jobs running in a shell -> % jobs -l [1] 83664 suspended nvim [2] 84330 suspended python [3] 84344 suspended python [4] 84376 suspended nvim [5] - 84701 ...
4
votes
1answer
144 views

kill %1 equivalent in fish

In bash, if I run kill %1, it kills a backgrounded command in the current shell (the most recent one, I believe). Is there an equivalent of this in fish? I haven't been able to find it online in a bit ...
1
vote
1answer
177 views

zsh: Why do I get suspended background processes even when I have `stty -tostop`?

I like my background processes to freely write to the tty. stty -tostop is already the default in my zsh (I don't know why, perhaps because of OhMyzsh?): ❯ stty -a |rg tostop ...
0
votes
2answers
562 views

Programmaticaly open new terminal with Bash and run commands, keeping job-control

In an X session, I can follow these steps: Open a terminal emulator (Xterm). Bash reads .bashrc and becomes interactive. The command prompt is waiting for commands. Enter vim 'my|file*' '!another ...
2
votes
1answer
30 views

Shell: Make a command go into a separate process group

When using a job control capable shell, each pipeline is normally placed into its own process group. When spawning a sub-process from an interactive program, such as an editor, the sub-process will ...
0
votes
1answer
321 views

Why does my process terminate upon log out despite nohup and disown?

I have an executable (a server made with Unity) which I want to continue to run after I log out. All the interwebs say that I should be able to accomplish this with nohup or disown or both. But it ...
0
votes
1answer
80 views

Arch linux arm proot installation on android cannot set terminal process group (bash) and no job control in shell

Recently on my android device I installed Arch via proot on termux but when I run the installation and enter bash it tells me that it cannot set the terminal process group and that it has no control ...
1
vote
2answers
171 views

less stops my script; why is that and how to avoid?

I have this Bash script named as s in current directory: #!/bin/bash pipe_test() { ( set -m; ( $1 ); set +m ) | ( $2 ) } pipe_test "$1" "$2" If I call e.g. ./s yes ...
1
vote
0answers
84 views

zsh bug: Unexpected process suspension

Update: simpler reproduction mdoc-test () { sleep 0 | sleep 0 cat } echo start |VISUAL=vim command vipe|mdoc-test # zsh: suspended (tty output) Posted to zsh mailing list. mdoc-test () { ...
0
votes
0answers
18 views

Is there a way to print a snapshot of a job that's in the background to standard output? [duplicate]

If I have a job that's running/paused in the background, is there a way of printing a snapshot of its activity to standard output?
1
vote
3answers
97 views

How to use one terminal with multiple interactive jobs without stopping them?

I have two shell-scripts, say client.sh and server.sh, which has to work simultaneously and give some useful output in watch-way. And I am able to use only one terminal. So I should switch between ...
0
votes
0answers
38 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 ...
1
vote
1answer
74 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
26 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
42 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
3k 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
604 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
26 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
308 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
241 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
331 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 ...
1
vote
0answers
103 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
168 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
54 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 ...
1
vote
0answers
4k 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 ...
2
votes
0answers
356 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
82 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 ...
4
votes
0answers
174 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
66 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
47 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
2k 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
158 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
26 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
116 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
167 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....
4
votes
0answers
1k 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
3k 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
78 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
62 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 ...