Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I require suggestions for writing a perl script which reduces or uses less CPU & Memory utilization during execution of a program .

I have a validation.pl perl script which executes fine but this script has to validate around 1000 files daily for every 5 minutes. So I have written a simple shell script with a simple for loop

for i in 1 2 3 4 5 . . . . . . 1000 do validation.pl $i done

As it needs to validate 1000 files where each validation.pl executes for 10sec's and it's taking more time then 5 minutes as they are executed sequentially .

So I have changed the syntax to execute the validation script in background mode to run parallely (1000 processes related to validation.pl execute at the same time for a minute)

for i in 1 2 3 4 5 . . . . . . 1000 do nohup validation.pl $i & done

Now it executes all the processes parallely but it's causing high CPU & Memory Utilization .In simple the server crashes because of high cpu & memory utilization. As one processes takes around 0.1% cpu & memory utilization 1000 processes almost uses 100% of utilization .

Is there a better way where I can write the shell script in perl and it should execute the validation.pl in parallel for all the inputs with less cpu & memory utilization during execution .

Please let me know what would be the best way to start working on it .


In reply to require sugesstions for writing a perl script by lazydev

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!
  • 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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (13)
    As of 2015-07-03 11:15 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (51 votes), past polls