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
1 answer
21 views

Is a pure number like "3" a valid jobspec?

I was reading a book about Linux. It states that to bring a process to foreground, use the fg command and a percent sign (%) followed by the job number. I did some testing and found that it works as ...
user avatar
1 vote
2 answers
25 views

Call other process after executing a blocking process in shell

I have a process that is blocking in nature. It is executed first. In order to execute the second process, I moved the first process to the background and executed the second process. Using the wait ...
user avatar
0 votes
0 answers
89 views

Why does foreground job ignore job control signals when Bash is running as PID 1?

When bash is invoked as pid 1 directly through the kernel option init=/bin/bash --login, it will issue something like this before prompting: bash: cannot set terminal process group (-1): Inappropriate ...
user avatar
1 vote
1 answer
44 views

How to kill all background and spawned processes of a bash script in its pre-exit handler?

I'm using the wait -n technique to perform max_jobs parallel tasks: #!/usr/bin/env bash cleanup() { echo "cleaning up..." } trap "cleanup" EXIT do_task() { echo "...
user avatar
2 votes
1 answer
198 views

Reliable way to get PID of piped background process

I need to retrieve the PID of a process piped into another process that together are spawned as a background job in bash. Previously I simply relied on pgrep, but as it turns out there can be a delay ...
user avatar
  • 43
0 votes
1 answer
92 views

Does Crontab queue a job?

I have scheduled a crontab job for every 2 minutes. But I have recently started to notice that the program takes more time (approx 7-8 mins)to finish execution. So does cron queues all the jobs that ...
user avatar
0 votes
1 answer
128 views

Reboot and relaunch a script if error

I have a script (not written by me, I cannot modify it) that has to run for days, that sometimes fails (exits with an error). In this case all I have to do is just reboot the server (there is no ...
user avatar
  • 2,235
0 votes
1 answer
71 views

Skip loop iteration(s) interactively on keypress

I am looping over an array and for each iteration, run a long during process, like this: !#/bin/bash arr=({1..100}) for i in "${arr[@]}"; do echo "$i" sleep 10 done Now I ...
user avatar
  • 20.5k
1 vote
1 answer
125 views

"kill %{job id}" vs "kill {job pid}"

I'm working with some tail -f path/to/my/log/file | grep pattern& and I need to kill the process as quick as possible. With classic kill {tail PID}, tail still displays its buffer and it takes ...
user avatar
  • 63
0 votes
0 answers
204 views

Why set -m is not working? Giving me error job control is turned off!

I am trying to execute an entryscript for docker container. I have build this image from php-fpm alpine linux (7.3 version). Once the container is started it should execute some commands in prior, I ...
user avatar
1 vote
0 answers
44 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 ...
user avatar
  • 2,145
0 votes
1 answer
23 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 ...
user avatar
  • 2,145
27 votes
3 answers
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 ...
user avatar
  • 494
1 vote
1 answer
300 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. ...
user avatar
  • 52.9k
2 votes
1 answer
118 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 ...
user avatar
  • 740
2 votes
0 answers
174 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 ...
user avatar
  • 1,181
0 votes
2 answers
74 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 ...
user avatar
  • 264
1 vote
0 answers
42 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 ...
user avatar
  • 21
1 vote
0 answers
75 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 ...
user avatar
0 votes
0 answers
472 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 ...
user avatar
3 votes
3 answers
118 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]- ...
user avatar
  • 88.7k
1 vote
1 answer
64 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 ...
user avatar
  • 224
4 votes
1 answer
563 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 ...
user avatar
  • 143
1 vote
1 answer
789 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 ...
user avatar
  • 1,287
0 votes
2 answers
2k 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 ...
user avatar
  • 17.3k
2 votes
1 answer
99 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 ...
user avatar
0 votes
1 answer
750 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 ...
user avatar
0 votes
1 answer
138 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 ...
user avatar
1 vote
2 answers
236 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 ...
user avatar
  • 528
1 vote
0 answers
136 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 () { ...
user avatar
  • 1,287
0 votes
0 answers
25 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?
user avatar
1 vote
3 answers
255 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 ...
user avatar
  • 255
0 votes
0 answers
75 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 ...
user avatar
  • 1,042
1 vote
1 answer
111 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 ...
user avatar
  • 3,623
0 votes
0 answers
27 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 `;' ...
user avatar
  • 101
1 vote
2 answers
49 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 ...
user avatar
0 votes
0 answers
4k 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 ...
user avatar
1 vote
1 answer
803 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 ...
user avatar
1 vote
0 answers
32 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 ...
user avatar
1 vote
1 answer
493 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 [...
user avatar
4 votes
2 answers
441 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 ...
user avatar
  • 571
1 vote
3 answers
666 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 ...
user avatar
  • 11
1 vote
0 answers
196 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 ...
user avatar
  • 65.8k
2 votes
1 answer
390 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 ...
user avatar
  • 551
0 votes
1 answer
80 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 ...
user avatar
1 vote
0 answers
5k 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 ...
user avatar
3 votes
0 answers
853 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 ...
user avatar
0 votes
1 answer
98 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 ...
user avatar
4 votes
0 answers
255 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 ...
user avatar
  • 4,269
1 vote
1 answer
69 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 ...
user avatar
  • 189

1
2 3 4 5