Stack Exchange Network

Stack Exchange network consists of 174 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.

8
votes
3answers
947 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
48 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 ...
2
votes
1answer
55 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
27 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 "...
11
votes
5answers
656 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
30 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
26 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
137 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
42 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
50 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
56 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
43 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
53 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
230 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
94 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
44 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
69 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
259 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
161 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
37 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 ...
0
votes
3answers
112 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
3answers
3k 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 ...
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
61 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
262 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 ...
2
votes
0answers
124 views

Shell job-control: possible to “rename” a running job?

In the shell (I'm using Bash), I frequently use Ctrl-Z and fg to suspend one job and foreground another. An example would be suspending a running instance of Vim and foregrounding a previously ...
1
vote
0answers
32 views

Mass killing stale backgrounded jobs

$ jobs [1] Stopped emacsclient -nw components/frontend/app/views/frontend/dashboard/index.html.erb [2] Stopped emacsclient -nw components/frontend/app/views/...
3
votes
4answers
5k 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:...
1
vote
1answer
69 views

why does kill work differently on job numbers than PIDs?

I was trying to demonstrate job control to a friend, when I ran into an unexpected behaviour. For certain commands, kill works with the job number, but not with the process ID. An example of the ...
3
votes
2answers
885 views

Is it possible to use commands like `fg` in a shell-script?

I am trying to create a fun Terminal Screensaver which consists of the cmatrix package (one that turns terminal in one similar to the movie The Matrix) and xprintidle to determine idle time of the ...
7
votes
3answers
1k views

Background, zombie, daemon and without ctty - are these concepts connected?

How these process concepts are related together - background, zombie, daemon and without controlling terminal? I feel that they are somehow close, especially through the concept of controlling ...
1
vote
1answer
2k views

What does “fg” stand for?

There is no manual entry for ctrl-z or fg. What does "fg" stand for in the context of job control? In other words, typing ctrl-z will suspend the current job drop me back into the shell, and the ...
1
vote
1answer
215 views

bash function that sends email after job is finished

I have written following function in my bashrc. It checks if a job is running every 5 seconds and sends email when job is finished. function jobcheck () { time=`date` jobstatus=`jobs $1` while [...
3
votes
1answer
461 views

Kill job in subshell with set -m

I have the following bash script: #!/bin/bash set -m ( (bin/pnvd &> /dev/null; kill 0) & sleep 2 perl integration-test/fuzz-test.pl || kill 0 kill %1 ) The first three ...
0
votes
0answers
28 views

Timed stopping and restarting of a a process [duplicate]

I am running a huge base backup to a cloud server that will take a few days to complete. When it is running it takes most of my internet connection. It is running in a terminal, so I can manually ...
1
vote
1answer
144 views

Cannot recover from sleeping tmux during SSH session

I've tried searching this on google but have been very unsuccessful so I've resorted to trying to get someone's help with this. On my local machine I do the following: $ tmux CTRL+b CTRL+z $ fg and ...
1
vote
0answers
76 views

How to run GDB in backround and bring it back?

I'm writing bash scripts that launch a test scenarios: several programs that connect to each other. If something crashed, I'd like to have a GDB command line. Looks something like that: myprogram &...
0
votes
0answers
64 views

jobs command gives wrong output

I'm using Red Hat 6, and typing jobs gives me: [2] + 12511 12510 Running find . | xargs grep -i "string" >../a.txt Those pids don't exist, and typing fg %2 outputs: ...
1
vote
0answers
26 views

Create a file at time 't' after PBS job execution begins

I submit a PBS job for 02:00:00 hours. I need to create a file in the PBS working directory at a specified time t (say 01:30:00 hours) after the job has begun to ensure that the job terminates ...
3
votes
1answer
1k views

Clean way to bring back background process to foreground in shell script

As an example: I have working shell script which starts up weblogic (which will continue to run) and then do deployment At the end I bring background process back to foreground, so that shell script ...
2
votes
1answer
28 views

Force a process to ignore/discard accumulated input while suspended?

So I've got an SSH reverse tunnel open, and I'm using tail to pipe the output of the sshd log into awk to detect certain login events and trigger an action. It looks like this: ssh -NR 2222:127.0.0.1:...
1
vote
1answer
43 views

prevent “[1] + done $scriptname” and “[1] 31303” to be shown

I have set up an alias for my mutt: alias mutt='$HOME/.mutt/run-notmuch-offlineimap & ; mutt'. Note: Changing my Alias to alias mutt='$HOME/.mutt/run-notmuch-offlineimap 2> /dev/null & ; ...
2
votes
0answers
43 views

Better way to go to background in a running command [duplicate]

Actually I do this to bring a running command from the foreground into the background: ctrl+z and then bg There is a better way? Because ctrl+z just pause the process and after that I need to run ...
2
votes
1answer
317 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
0answers
28 views

How can I make sublime appear in the jobs list?

How can I make Sublime Text appear in the jobs list when started from the command line? For example... $ subl $ jobs ... doesn't show anything. I want to do this because my prompt is configured to ...
-2
votes
1answer
4k views

at command not found [closed]

Following on from Cron job for 7 days alone not followed by multiple weeks, I am trying to use at but it shows at: command not found. By default it seems that Red Hat Enterprise Linux Server release ...
1
vote
1answer
261 views

How do I keep a prompt running in background? [duplicate]

I am developing a web application in Phoenix and I also just started discovering Unix process management. I put my app in background, like this: vagrant@dev:/srv/my_app$ iex -S mix phoenix.server &...
1
vote
2answers
998 views

Ampersand after for loop on shell scripts

What is the difference between running following commands on terminal? command1 for i in {1..3}; do ./script.sh >& log.$i & done and command2 for i in {1..3}; do ./script.sh >& ...
19
votes
2answers
1k views

+/- after a job in the background is done

Run a job in the background $ command & When it's done, the terminal prints [n]+ command or [n]- command So sometimes it's a plus and other times it's a minus following [n]. What ...
2
votes
0answers
46 views

why did a local crash kill my remote jobs?

Yesterday I made an interesting observation. I sit on my local office computer (Ubuntu 16.04) and I have several remote jobs (long CFD simulations) on our cluster (CentOS7) running. All jobs were ...