|We don't bite newbies here... much|
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 doneAs 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)
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 .