Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Simple Log Rotate Problem

by monger (Friar)
on Nov 13, 2003 at 22:01 UTC ( [id://306945]=note: print w/replies, xml ) Need Help??


in reply to Re: Simple Log Rotate Problem
in thread 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.

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

Replies are listed 'Best First'.
Re: Re: Re: Simple Log Rotate Problem
by idsfa (Vicar) on Nov 13, 2003 at 22:38 UTC

    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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://306945]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-19 02:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found