Questions tagged [job-control]

69 questions
219
votes
8 answers

Linux: kill background task

How do I kill the last spawned background task in Linux? Example: doSomething doAnotherThing doB & doC doD #kill doB ????
flybywire
  • 261,858
  • 191
  • 397
  • 503
115
votes
7 answers

In what order should I send signals to gracefully shutdown processes?

In a comment on this answer of another question, the commenter says: don’t use kill -9 unless absolutely necessary! SIGKILL can’t be trapped so the killed program can’t run any shutdown routines to e.g. erase temporary files. First try…
system PAUSE
  • 37,082
  • 20
  • 62
  • 59
82
votes
3 answers

Run a shell script and immediately background it, however keep the ability to inspect its output

How can I run a shell script and immediately background it, however keep the ability to inspect its output any time by tailing /tmp/output.txt. It would be nice if I can foreground the process too later. P.S. It would be really cool if you can also…
82
votes
5 answers

Wait for bash background jobs in script to be finished

To maximize CPU usage (I run things on a Debian Lenny in EC2) I have a simple script to launch jobs in parallel: #!/bin/bash for i in apache-200901*.log; do echo "Processing $i ..."; do_something_important; done & for i in apache-200902*.log; do…
mark
  • 6,308
  • 8
  • 46
  • 57
59
votes
7 answers

Why can't I use job control in a bash script?

In this answer to another question, I was told that in scripts you don't have job control (and trying to turn it on is stupid) This is the first time I've heard this, and I've pored over the bash.info section on Job Control (chapter 7), finding…
system PAUSE
  • 37,082
  • 20
  • 62
  • 59
44
votes
5 answers

How can I suppress “Terminate batch job (Y/N)” confirmation in PowerShell?

When I press Ctrl+C in PowerShell, I receive: Terminate batch job (Y/N)? Similar to https://superuser.com/questions/35698/how-to-supress-terminate-batch-job-y-n-confirmation, except for Windows PowerShell. Does PowerShell provide any more control…
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
28
votes
5 answers

Does linux kill background processes if we close the terminal from which it has started?

I have an embedded system, on which I do telnet and then I run an application in background: ./app_name & Now if I close my terminal and do telnet from other terminal and if I check then I can see this process is still running. To check this I have…
Chirag
  • 607
  • 1
  • 6
  • 17
13
votes
3 answers

Background and foreground bash/zsh jobs without adding newlines in "continued/suspended" messages

I have a process that goes something like this: Run a command that generates a bunch of results in a bunch of files Open a file in vim Edit one of the results Background vim, get the next result, foreground vim Repeat until the list is…
Kevin Burke
  • 61,194
  • 76
  • 188
  • 305
11
votes
1 answer

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 ioctl for device bash: no job control in this…
Li-Guangda
  • 341
  • 1
  • 4
  • 14
10
votes
2 answers

Does Linux allow process group ids to be reassigned to processes?

Suppose pid X is a process group leader and X terminates, but other processes in the process group remain running (with X as their pgid). Will Linux prevent the value X from being assigned as a pid to a new process? I ask this because of a failure…
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
9
votes
4 answers

(Hadoop) MapReduce - Chain jobs - JobControl doesn't stop

I need to chain two MapReduce jobs. I used JobControl to set job2 as dependent of job1. It works, output files are created!! But it doesn't stop! In the shell it remains in this state: 12/09/11 19:06:24 WARN mapred.JobClient: Use…
Pietro Luciani
  • 247
  • 1
  • 4
  • 14
6
votes
4 answers

Job control in linux with C

What I know: When a process is running I can press Ctrl+Z and suspend it. The with bg and fg commands I can either run it in "background" or "foreground" mode. What I'm aksing: Is there a way to suspend a process, send it to run in background or…
Yasser Souri
  • 1,967
  • 2
  • 19
  • 26
6
votes
1 answer

Launch process from Bash script in the background, then bring it to foreground

The following is a simplified version of some code I have: #!/bin/bash myfile=file.txt interactive_command > $myfile & pid=$! # Use tail to wait for the file to be populated while read -r line; do first_output_line=$line break # we only need…
David Bailey
  • 940
  • 1
  • 10
  • 21
6
votes
1 answer

bg / fg inside a command line loop

ctrl-z (^z) acts in ways I do not understand when done inside a loop executed from a terminal. Say I type for ii in {0..100}; do echo $ii; sleep 1; done then I hit ^z. I'll get: [1]+ Stopped sleep 1 I can resume the job using fg…
Andrew Schwartz
  • 4,440
  • 3
  • 25
  • 58
5
votes
1 answer

Difference between foreground job and background job

In Linux, what is the difference between a foreground job and a background job?
Yasser Souri
  • 1,967
  • 2
  • 19
  • 26
1
2 3 4 5