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
2answers
513 views

How to resume a program when logged in with different session

Here is the scenario: Let's say that I log into my server via ssh and start an emacs or vi (or whatever other program) session. Then my ssh connection disconnects. Is there a way for me to reconnect ...
1
vote
2answers
890 views

Job control over a Bash script

I have a Bash script of a thousand lines each containing an ffmpeg command. I start this with source script and it runs just fine. However, when I try to take control of this script in various ways, ...
1
vote
1answer
49 views

Run program while computer is cool

I'm trying to compile a program on a computer with inadequate cooling. The program, specifically, is the linux-ck kernel with -mtune=native march=native processor-specific optimizations, so simply ...
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, ...
1
vote
1answer
36 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
77 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 ...
1
vote
1answer
306 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 [...
1
vote
1answer
48 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 & ; ...
1
vote
2answers
287 views

Result of combination of Ctrl+c and then Ctrl+z in shell

Which signal will be sent to the running process after sending the Ctrlc after 500ms of Ctrlz? I have tried to give the Ctrlc after Ctrlz but I didn't get the exact answers for this.
1
vote
1answer
651 views

fg a bg process because you forgot to redirect output to /dev/null

I did Ctrl+Z bg with the intention of disowning next, but I forgot to redirect, now I cant get to my terminal because the scrolling of the output (tarballed a huge directory with verbose set). How do ...
1
vote
1answer
52 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
1answer
52 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
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 ) & ) ...
1
vote
1answer
291 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
1answer
59 views

Replacement queue now that batch doesn't accept input files?

Background I work at a research institute, and have for a long time used the batch command to submit job queues to our machines. However, a recent update changed the batch command to be POSIX-...
1
vote
1answer
2k views

Running commands after ampersand symbol & in a remote ssh session

I have a shell script that initiates a long, resource-intensive command on several different machines. In order to execute the script on each machine in parallel, I have an ampersand symbol after ...
1
vote
2answers
6k views

How to Kill Difficult Task in Mac Terminal

I ran this grep: grep -r "\-\-\-foo\-\-\-" * | grep -vi bar For the past 5 minutes my Mac has been running hot (I can hear the fan) and I can't hit Ctrlz or x or c to kill the current task. Even ...
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 ...
1
vote
2answers
1k 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 >& ...
1
vote
1answer
400 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 ...
1
vote
2answers
322 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 ...
1
vote
0answers
33 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
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
0answers
43 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 ...
1
vote
0answers
100 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 "...
1
vote
0answers
51 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 ...
1
vote
0answers
33 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/...
1
vote
1answer
196 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
83 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 &...
1
vote
0answers
30 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 ...
1
vote
1answer
458 views

Submitting jobs with sequential completion

If I have numerous jobs that rely on environment variables, how can I submit them sequentially? Here is my attempt that has not been working, week 6 is always submitted (and finishes) before week 5. ...
1
vote
1answer
839 views

Application in terminal still running but not directly accessible [duplicate]

Possible Duplicate: How to suspend and bring a background process to foreground I have kind of an odd problem which I haven't encountered before. Here's what I did: I started an application with ...
0
votes
1answer
290 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 ...
0
votes
2answers
2k views

How to know when a job in screen finishes?

Is it possible to know if a script executed inside a screen session finished or not? The script can be seen by typing jobs and I would like to terminate the screen session when the script is finished. ...
0
votes
2answers
994 views

UNIX: Submit job only after previous job completes?

I would like to submit the same .sas job iterating over an argument, but I would like job only to be submitted after the previous is completed. Here is my attempt: #!/bin/ksh export weeks="1 ...
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 ...
0
votes
3answers
155 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 =>...
0
votes
2answers
286 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 ...
0
votes
1answer
278 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 ...
0
votes
1answer
972 views

How to make a scheduled task based on a file creation time?

The supercomputer I run my Analysis uses SGE to do the job management and requires each job duration not longer than 24 hours. And this feature is causing me quite a headache. Sadly, I was asked to ...
0
votes
1answer
95 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....
0
votes
1answer
90 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
629 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 ...
0
votes
1answer
59 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 ...
0
votes
0answers
29 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 ...
0
votes
0answers
80 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: ...
0
votes
1answer
36 views

Starting up and keeping up a process

I am having an Ubuntu box on which I am having a Haskell process (think of it as a random server process) that I built. I want to start it on boot and restart it in case it fails for whatever reason (...
0
votes
1answer
246 views

How to dynamically chose PBS queue during job submission

I run a lot of small computing jobs in remote cluster where job submission is managed by PBS. Normally in a PBS (bash) script I specify the queue that I would like to submit the job through the ...
0
votes
1answer
475 views

When executing a command, it is automatically suspended

The problem happened on one of my local machines with CentOS 6. I ssh to it from my MacBook trying to test a script, which is in /usr/local/bin. However, whenever I tried to execute the command, it is ...
0
votes
1answer
943 views

safely killing a background process

I'm writing data to a pipe in a parent process. The parent process creates a background job that reads data from the pipe & write it to the screen & to a log file. How can I know when to kill ...