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

Re: one process occupying the whole cpu



Kjetil brinchmann Halvorsen:
> 
> This si my shell (bash) script:
> 
> # shell script to install all the packages in ~/R/allpackages,
> # to ~/R/allinstall . Should be run from ~/R/Recommend .
> #
>  for FILE in ~/R/allpackages/*z
>  do
>     if [ -f $FILE ]
>     then
>        nice R CMD INSTALL  --library=~/R/allinstall --no-test-load    \
>               --no-configure --html --no-libs --no-exec --resave-data $FILE \
>                  || echo "Problems encountered during processing of $FILE" &

The ampersand (&) at the end of the previous line sends the nice'd
process to the background. The loop continues immediately after the
command is started, so within a few seconds you have as many 'CMD'
processes as you have files matching ~/R/allpackages/*z.

> Any tips on how to write the script so that it becomes "nice"?

Just remove the ampersand. Alternatively, if you want to run a few
processes in parallel to use multiple cores, you can replace the whole
loop with a find … | xargs construct. See xargs' -P option.

J.
-- 
I wish I had been aware enough to enjoy my time as a toddler.
[Agree]   [Disagree]
                 <http://www.slowlydownward.com/NODATA/data_enter2.html>

Attachment: signature.asc
Description: Digital signature


Reply to: