my thought is to: first, immediately fire a command to every one of them at once, asking every one of them at once to cvs update themselves and then to send back a notification, of success or of failure, by some appropriate means.... heck, maybe you literally use e-mail to do it.

But now you're inventing a new process.

He already has a process. One that works. Whatever mechanisms he uses -- he mentions a "shell script" which generally means invoking one or more executables -- it currently does one at a time and waits for the process to finish logging the progress as it goes and the checking the log locally for errors.

Whilst kicking the jobs off in parallel using '>logN &' is a very simple extension of what he has now, it has the caveat of now needing to institute some mechanism by which it can wait for all the jobs to finish so the logs can be checked; or add the checking into each of the background processes plus some mechanism for notification of failures; etc. etc.

Alternatively, it is easy to convert most most existing shell scripts to Perl scripts. That's the basic raison d'etre for Perl's existence. It is easy to envisage his current shell script looking something like (ignore the syntax, csh isn't my thing):

foreach $webserver ( `cat servers` ) { $result = `ssh server cvs update ... `; if( echo $result | grep Error ) { echo 'problem with server $webserver' } }

and easily converting that to something like:

#! perl my @webservers = <>; for my $job ( @webserver ) { my $result = `ssh $job cvs update ...`; print "Server $job had errors" if $result =~ m[Error]; }

And it is a trivial extension of that, to do the same thing concurrently using threads:

#! perl use threads; my @webservers = <>; my @threads; for my $job ( @webserver ) { push @threads, async{ my $result = `ssh $job cvs update ...`; print "Server $job had errors" if $result =~ m[Error]; }; } $_->join for @threads.

It's just the path of least resistance really.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


In reply to Re^4: Do I need threads? by BrowserUk
in thread Do I need threads? by TechFly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.