On Aug 14, 2009, at 21:08 , [email protected] wrote:
is there a way in shell scripts (primarily bash) to background some tasksand then wait for them to complete before doing another command?I've got a nightly log analysis run that has lots of things in the form(greatly simplified for explination) cat $LOGS |tool1 >report1 cat $LOGS |tool2 >report2 cat $LOGS |tool3 >report3 followed by a section at the end that calls a script that does head report1 >>e-mail head report2 >>e-mail head report3 >>e-mailit would speed things up drasticly if I could do the report generation in parallel, but I need a way to be sure that they have all completed beforegenerating the final e-mail.
There is, it's unsurprisingly called "wait". If you want to wait only for some, you can save pids of backgrounded commands (they go into $!) and wait on a list of pids; by default it waits on all backgrounded jobs.
-- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected] system administrator [openafs,heimdal,too many hats] [email protected] electrical and computer engineering, carnegie mellon university KF8NH
PGP.sig
Description: This is a digitally signed message part
_______________________________________________ Discuss mailing list [email protected] http://lopsa.org/cgi-bin/mailman/listinfo/discuss This list provided by the League of Professional System Administrators http://lopsa.org/
