Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Close a file and reopen a new one at midnight

by aitap (Deacon)
on Jan 14, 2013 at 18:44 UTC ( #1013258=note: print w/ replies, xml ) Need Help??


in reply to Close a file and reopen a new one at midnight

It looks like you are running a UNIX-like system. You may want to install a signal handler to reopen the filehandle and either alarm at midnight (and catch the ALRM signal) or send some signal (USR1, for example) via cron daemon and handle it. You can even automatically compress and/or remove old files using logrotate if you want.

Sorry if my advice was wrong.


Comment on Re: Close a file and reopen a new one at midnight
Re: Close a file and reopen a new one at midnight
by 0day (Sexton) on Jan 14, 2013 at 19:18 UTC
    my $timeout = 24*60*60 - ($hour*3600 + $min*60 + $sec); while(1) { eval { local $SIG{ALRM} = sub { die; }; alarm($timeout); while (my $line = <$sock>) { ................. } alarm(0); }; $timeout = 24*60*60; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013258]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2014-07-28 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (204 votes), past polls