f



jobs in jobs; jobs control

When I did a for loop to start some background jobs
i.e
for ... do
 command &
done &

when I type jobs, I can only see the for loop jobs, after the for loop
finishes, I can't see any jobs with the command jobs... I know the
"hidden" jobs are running since they are producing data... how can I
job control them?

Regards

0
Ben
5/23/2007 5:13:10 AM
comp.unix.shell 15484 articles. 2 followers. Post Follow

2 Replies
995 Views

Similar Articles

[PageSpeed] 19

Ben wrote:
> When I did a for loop to start some background jobs
> i.e
> for ... do
>  command &
> done &
> 
> when I type jobs, I can only see the for loop jobs, after the for loop
> finishes, I can't see any jobs with the command jobs... I know the
> "hidden" jobs are running since they are producing data... how can I
> job control them?
> 
> Regards
> 

run the loop in the foreground:

for ...
do
  command &
done
jobs

-- 
Michael Tosch @ hp : com
0
Michael
5/23/2007 8:22:41 PM
In article <1179897190.132584.60250@u30g2000hsc.googlegroups.com>,
 Ben <chinese.central@googlemail.com> wrote:

> When I did a for loop to start some background jobs
> i.e
> for ... do
>  command &
> done &
> 
> when I type jobs, I can only see the for loop jobs, after the for loop
> finishes, I can't see any jobs with the command jobs... I know the
> "hidden" jobs are running since they are producing data... how can I
> job control them?

A process can only control its child processes, not further descendant 
processes.  By putting the loop in the background you require a child 
for the loop, and as a result all the commands run in grandchild 
processes, which your original shell can't control.

If your system has the "pstree" command this is a way to see this 
process hierarchy.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
0
Barry
5/24/2007 4:09:13 AM
Reply: