parallel
[Top][All Lists]
Advanced

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

Re: Dynamically changing remote servers list


From: Douglas A. Augusto
Subject: Re: Dynamically changing remote servers list
Date: Wed, 27 Aug 2014 15:49:38 -0300
User-agent: Mutt/1.5.23 (2014-03-12)

On 27/08/2014 at 08:38,
Ole Tange <ole@tange.dk> wrote:

> 'cat' is not atomic, so you will be inviting a race condition, where
> the 'cat' runs exactly when GNU Parallel reads the file. 'mv' is
> atomic - use that instead.

Hi,

You're right, I was afraid of some unintended side-effect like that. I'll
think about the daemon thing. For now, this is the updated script:

   cp original.slf updated.slf
   while [ 1 ] ; do
      nice parallel --timeout 1000% --nonall -j0 -k --slf original.slf --tag 
echo | \
         sed -e 's/\t$//' -e '/\t/d' > tmp.slf
      if ! cmp -s tmp.slf updated.slf; then
         mv tmp.slf updated.slf
      fi

      sleep 10
   done &
   parallel --slf updated.slf ...

And below a version that also preserves the server options if any (the full
server entry), such as '8/server.net':

   cp original.slf updated.slf
   while [ 1 ] ; do
      nice parallel --timeout 1000% --nonall -j0 -k --slf original.slf --tag 
echo | \
         sed -e 's/\t$//' -e '/\t/d' | \
         nice parallel -k grep -m 1 -F {} original.slf > tmp.slf
      if ! cmp -s tmp.slf updated.slf; then
         mv tmp.slf updated.slf
      fi

      sleep 10
   done &
   parallel --slf updated.slf ...

-- 
Douglas A. Augusto



reply via email to

[Prev in Thread] Current Thread [Next in Thread]