File::Tail just...stops.

D

Don W.

I wrote a program that would continuously dump the output of a file to
syslog, using File::Tail and Tie::Syslog. Problem is, after about two
days of operation, the program just stops tailing -- it's still
running, and if I strace it, I can see that the file is being
stat()ed, but no data is being sent across the wire to the syslog
server. If I restart the program, it starts tailing again.

Any clues? This is what I'm using for the File::Tail constructor:

my $tail = File::Tail->new(
'name' => $file,
'maxinterval' => '1'
);

I can't find anything in the man page that would explain this
behaviour, but it wouldn't be the first time I've RTFM and missed
something.

Thanks-in-advance!
 
B

Bill

Don said:
I wrote a program that would continuously dump the output of a file to
syslog, using File::Tail and Tie::Syslog. Problem is, after about two
days of operation, the program just stops tailing -- it's still
running, and if I strace it, I can see that the file is being
stat()ed, but no data is being sent across the wire to the syslog
server. If I restart the program, it starts tailing again.

Any clues? This is what I'm using for the File::Tail constructor:

my $tail = File::Tail->new(
'name' => $file,
'maxinterval' => '1'
);

Don't see anything wrong in what you've posted. If you are still
stumped, maybe you can try debugging by setting $tail->nowait(1); to not
wait and sleeping a second in the loop via sleep 1;, then printing a a
debug message within your loop, and see whether anything changes in the
file or object status after the two days.

--hth
 
B

Benjamin Franz

(e-mail address removed) (Don W.) wrote in
I wrote a program that would continuously dump the output of a file to
syslog, using File::Tail and Tie::Syslog. Problem is, after about two
days of operation, the program just stops tailing -- it's still
running, and if I strace it, I can see that the file is being
stat()ed, but no data is being sent across the wire to the syslog
server. If I restart the program, it starts tailing again.

At a guess, your log is getting rotated. Leaving you tailing the _old_ (now
static) log instead of the new one.
 
B

Benjamin Franz

(e-mail address removed) (Randal L. Schwartz) wrote in
Benjamin> At a guess, your log is getting rotated. Leaving you tailing
Benjamin> the _old_ (now static) log instead of the new one.

But File::Tail (at least recent versions) know about that kind of
stuff, and automatically close and reopen the log.

Good point.

Anyway I misread his posting - he is tailing another file and feeding the
results to syslog rather than tailing a syslog output file. His complaint
appears to be that it never arrives at the syslog server. But what he
posted doesn't tell whether or not File::Tail is reading or not - it just
tells us that it isn't being sent to his syslog server. The problem could
be anywhere in his code given what he has posted so far.

So, my revised answer is "Open a debugging log file locally and write
each read File::Tail generated line to it". That will at least either
eliminate or prove that it is File::Tail that is the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top