Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Simple Log Rotate Problem

by shockme (Chaplain)
on Nov 13, 2003 at 21:56 UTC ( #306940=note: print w/ replies, xml ) Need Help??


in reply to Simple Log Rotate Problem

Following the move, whatever service is writing to the file will need to be restarted as well, for example:
system("/etc/init.d/syslog restart") == 0 or ...
I've seen situations where the application would continue writing to the old file until the service was restarted. Odd but true, and it might explain some of what you're seeing.

If you can, check /etc/logrotate.conf or any of the files in /etc/logrotate.d, and you'll probably see where certain services are being restarted following the rotation.

If things get any worse, I'll have to ask you to stop helping me.


Comment on Re: Simple Log Rotate Problem
Download Code
Re: Re: Simple Log Rotate Problem
by meetraz (Hermit) on Nov 13, 2003 at 22:00 UTC
    Since the log file is on an "H:" drive, this appears to be a Win32 system. Unlike Unix, on Win32 you can't move a file that's in use, so I don't think this would be in issue there. (and the logrotate service doens't exist)
      I see your point (and based on monger's reply, it appears that you are correct). However, I've had situations where a *nix directory was mounted to a Windows box, and scripts would run on the Windows box rather than the *nix machine. Weird? Yes, but I didn't set it up ...

      So, I didn't assume that H: precluded the existence of a *nix environment.

      If things get any worse, I'll have to ask you to stop helping me.

Re: Re: Simple Log Rotate Problem
by monger (Friar) on Nov 13, 2003 at 22:01 UTC
    Following the move, whatever service is writing to the file will need to be restarted as well, for example: system("/etc/init.d/syslog restart") == 0 or ... I've seen situations where the application would continue writing to the old file until the service was restarted. Odd but true, and it might explain some of what you're seeing. If you can, check /etc/logrotate.conf or any of the files in /etc/logrotate.d, and you'll probably see where certain services are being restarted following the rotation.

    Thanks for the idea. It could be the issue, but Perl is what is creating these files. They are snapshots of the real log files. The script will run, creating vpnwarn.out. Upon next execution, after Perl has exited, it fails with Can't unlink file: No such file or directory at ./vpnwarn.pl line 28. (see reply to earlier post). If the previous instance of Perl is mucking with it, let me know.

    Also, there is no logrotate here. It's cygwin on a Doze box.

    Monger

      dingdingdingdingdingdingding

      The magic word is cygwin, which means that you do have a unix-y environment. shockme's node touches on exactly what is going on. If a process has a filehandle open when you move the old vpnwarn.out, that process will continue writing to the same file, now named vpnwarn.old. If another process comes along and connects to the new vpnwarn.out, then both files will continue to grow. (tested under cygwin)

      It gets worse: If the (still in use) vnpwarn.old file is unlinked while the filehandle is still open, it can continue to grow without even showing up when you list the directory. You can chew up a whole hard drive's capacity that way.

      You say that perl is creating these files. When logging, try to follow an "open, write, close" cycle as much as possible. This not only flushes your output (in case you forgot to turn off buffering), but avoids the "phantom menace" of unlinked but expanding files.


      My parents just came back from a planet where the dominant life form had no
      bilateral symmetry, and all I got was this stupid F-Shirt.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2014-09-19 12:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (137 votes), past polls