Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- script crashes with "Too many open files"
- Bennett Haselton
December 18, 2008, 9:44 am
rate this thread
I'm already using version 3.12 which according to that page is the
most recent available.
Even if you don't know the details of how Mail::Bulkmail works, I
suspect someone familiar with Perl or Linux internals may have a
suggestion on how to work around this problem.
After Mail::Bulkmail has been invoked, I think, a few hundred times,
the script crashes with the error message:
Could not initilize method (GOOD) to value (/var/www/good.txt) :
Could not open file /var/www/good.txt : Too many open files at ./send-
pending-messages-using-bulkmail.pl line 154.
Now the /var/www/good.txt file is specified in my bulkmail-config.txt
file as the file to write "good" addresses to. While the script is
running, the lsof command shows me these instances of handles on the
"good" file being already open:
peacefire:/var/www/html/circumventor# lsof -u root | grep good
send-pend 23961 root 6w REG 0,125 20427325
send-pend 23961 root 10w REG 0,125 20427325
send-pend 23961 root 13w REG 0,125 20427325
where the number of lines is the number of times that
Mail::Bulkmail::bulkmail() has been called. In other words, it looks
like each instance bulkmail() is opening a new file handle on good.txt
and not closing it properly.
After the script crashes, all the handles get closed automatically, so
I just have to restart the script and it's back up and running. But
can anyone guess a workaround that would allow the script to run
In the bulkmail config file I have these lines:
#log our errors
ERRFILE = /var/www/error.txt
BAD = /var/www/bad.txt
GOOD = /var/www/good.txt
banned = /var/www/banned.txt
So if I just commented the lines out completely, that might solve the
problem as nothing is logged any more, but I'd like to do some logging
so I'm hoping for a cleaner solution.
Re: script crashes with "Too many open files"
BH> After Mail::Bulkmail has been invoked, I think, a few hundred times,
BH> the script crashes with the error message:
that line is a big clue. why do you invoke that module a few hundred
times? do you mean create new bulkmail objects or call some method a few
hundred times? without looking, i would expect a single bulkmail object
to be created and given the bulk addresses in a method.
BH> where the number of lines is the number of times that
BH> Mail::Bulkmail::bulkmail() has been called. In other words, it looks
BH> like each instance bulkmail() is opening a new file handle on good.txt
BH> and not closing it properly.
but why are you creating a new instance over and over? i suspect you are
not using the module properly.
Uri Guttman ------ firstname.lastname@example.org -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
- » FAQ 3.26 Where can I learn about object-oriented Perl programming?
- — Next thread in » PERL Discussions
- » FAQ 3.15 How can I make my Perl program run faster?
- — Previous thread in » PERL Discussions