Perl script doesn't respond for more than 10 Hours
This Perl script can run in endless loop with random number of sleep time until user abort (like CTRL + C)
code:
$| = 1;
if($loginStatus==2){ $successCounter++;
aSleep();
}
else{
$failedCounter++;
aSleep();
}
print STLOG_FILE "[".DateAndTime()."] - $failedCounter -Attempts Failed\n\n";
print $failedCounter."- Attempts Failed \n\n";
#aSleep()
sub aSleep(){
$| = 1;
my $dT=DateAndTime();
my $WAIT_TIME;
print "\n Time ".qx(date /T)." ".qx(time /T)."\n";
print STLOG_FILE "[".DateAndTime()."] - :Time :".qx(date /T)." ".qx(time /T)."\n";
$WAIT_TIME=scalar((rand()*200)+30);
print STLOG_FILE "[".DateAndTime()."] - Waiting (in Seconds)....".$WAIT_TIME."\n\n";
print "\n\n Waiting (in Seconds)....".$WAIT_TIME."\n\n";
sleep($WAIT_TIME);
return 0;
}
this script runs fine for 4 Hours, later it takes 10-15 Hours to return from aSleep() and print statements. I see this behavior in logs.It checks status in MIB browser and also has to access remote device.
Main concern : If I have entries in log from 6PM to 9PM of Monday, then continuation in log is on Tuesday at 9 AM or so.
Last edited by Tyron Babu; 01-24-2012 at 06:05 AM.
Reason: Adding more information
|