sunshine_august has asked for the wisdom of the Perl Monks concerning the following question:

Hi, all monks:
I want to rotate rsync server's log file by hourly, is there any module can do this?
  • Comment on [OT]Is there any module can rotate log file?

Replies are listed 'Best First'.
Re: [OT]Is there any module can rotate log file?
by svenXY (Deacon) on Oct 14, 2008 at 07:35 UTC
    Hi,
    how about Logfile::Rotate - which a simple search on CPAN would have found as first hit?
    Regards,
    svenXY
      Logfile::Rotate may help if I run it in an hour interval

      But, I am really curious about that what will happen if the Logfile::Rotate rotate the log file while the rsync server is also updating the log file? Will be there some log lost?

        It depends. You haven't provided enough information.

        I assume the logfile rotation would be happening on the system being rsync'd FROM.

        You'll have to check how rsync does its directory comparison, but I think it does it once at the start of the sync. So if the rotation happens after that point, but before the copies are complete, then your latest log slice might be missed by the rsync.

        But it's not "lost" -- it's just not rsync'd.

        All you have to do is set up the Rotate's to happen every n minutes (60, 120, whatever...), and rsync in the middle of those intervals. In that case, unless you've accumulated more data in n/2 minutes than rsync can move, rsync isn't going to conflict with the rotation...


        Mike
Re: [OT]Is there any module can rotate log file?
by andreas1234567 (Vicar) on Oct 14, 2008 at 07:49 UTC
    See also Log::Dispatch::FileRotate.
    --
    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]