[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: need help making shell script use two CPUs/cores



Bob Proulx put forth on 1/9/2011 3:12 PM:

> GNU xargs has an extension to run jobs in parallel.  This is already
> installed on your system.  (But won't work on other Unix systems.)
> 
>   for k in *.JPG; do echo $k; done | xargs -I{} -P4 echo convert {} -resize 1024 {}
> 
> Verify that does what you want and then remove the echo.

Thank you Bob.  This is EXACTLY what I was looking for.  It does exactly what I
want, in the precise way I want.  And it's such a simple modification of my
original script, not requiring a big rewrite.  Excellent. :)

I'm using -P2 as the target system is an old dual proc server, two single core
CPUs.  I made three timed runs against 11 camera photo files, first using -P4,
then -P2, then the original script.  The two process run was 5 seconds faster
and consuming half as much memory as the 4 processes run, and the -P2 overall
run time was almost exactly half that of the original script.

Very excellent indeed.  Thanks again Bob.  You rock.  :)

-- 
Stan


Reply to: