[GLLUG] Questions about shell scripting

Charles Ulrich charles at bityard.net
Thu Jun 14 20:31:54 EDT 2012


On 2012-06-14 18:20, David Lee Lambert wrote:
> 2 quick questions:
>
> 1:  Is it possible to run a shell function in the background with
> "&"?

Yes, but it might depend on the shell.

> 2:  What's a good idiom for starting several jobs in the
> background,  then waiting for them all to complete,  returning
> nonzero and printing an error if any of them fail?

I don't know of a way to monitor the return status of the background 
jobs (which is not to say it isn't possible), but you may have to have 
them write their status to a pipe or file or something and check that 
periodically.

Also check out GNU parallel and pexec, these are utilities for running 
parallel jobs from the shell.

Charles


More information about the linux-user mailing list