The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to find the jobs running in background and stop srinivas_paluku Shell Programming and Scripting 7 01-28-2008 08:41 PM
background jobs exit status and limit the number of jobs to run GrepMe Shell Programming and Scripting 1 06-11-2007 06:56 PM
Background jobs Jeremiorama High Level Programming 1 11-25-2005 09:48 AM
background jobs qsi Shell Programming and Scripting 4 11-24-2004 05:45 AM
exit unix, but says running jobs yls177 UNIX for Dummies Questions & Answers 6 10-25-2002 03:08 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-02-2007
hyennah hyennah is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 14
Issues with exit after running jobs in background

I have the following sample script to run a script the jobs with the same
priority(in this case field3) in parallel; wait for the jobs to finish
and run the next set of jobs in parallel.When all the lines are read
exit the script.
I have the following script which is doing evrything I want to, but the
script does not exit after completing all the jobs.
Would appreciate any input as to why the script doesnt exit

#!/bin/ksh


a=1

cat abc.txt | while read field1 field2 field3

do

F1=$field1
F2=$field2
priority=$field3

if[[ $priority -eq $a ]] ; then

run_some_job.ksh - $F1 -$F2 $F3&

else
wait
a=`expr $a + 1`
fi

done

exit
  #2 (permalink)  
Old 04-03-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
According to the ksh man page: "Waits for the specified job and report its termination status. If job is not given then all currently active child processes are waited for."

My feeling is that you have a child process to operate your loop. Then your wait statement inside the loop is actually waiting for the loop to terminate. Put a "ps -f" in front of the "wait" to see what you are waiting for.

You may eliminate the child process by losing your UUOC.

Instead of:
cat file | while read ; do
done

Try:
exec < file
while read ; do
done

or try:
while read ; do
done < file
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0