You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Carlos <Ca...@pbsinet.com> on 2004/11/15 21:05:19 UTC

Rotating catalina.out with Webmin

Hi Forum,

 

Could someone recommend settings for using the log rotation of Webmin in
order to rotate catalina.out (any cautionary measures)?  I just created an
entry in Webmin to rotate the catalina.out file weekly with all the default
settings (keeping the last four copies).  Are there any scripts I should run
before or after the rotation is carried out?


Re: Rotating catalina.out with Webmin

Posted by er...@swapsimple.com.
On Mon, Nov 15, 2004 at 03:39:01PM -0600, Filip Hanik - Dev wrote:
> this was not the case when using a java.io.FileOutputStream(), so I assume you tried and verified this :)

	You are confused.  It _is_ the case with FileOutputStream.  The only
way it could be otherwise is if the output stream re-opens the file, either
on every write, or when it notices that the file name no longer refers to
the same file.

Create aa.java with this code:

import java.io.*;
public class aa
{
    public static void main(String[] args) throws Exception
    {
        FileOutputStream f = new FileOutputStream(args[0]);
        f.write(80); f.flush();
        synchronized(f) { f.wait(5 * 1000); }
        f.write(81); f.flush();
    }
}

And run this:
java aa foo &
mv foo bar

Notice that the output of the second write (which occurs after the file
is renamed) is in the original file (bar), not in a new foo.

eric

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Rotating catalina.out with Webmin

Posted by Filip Hanik - Dev <de...@hanik.com>.
this was not the case when using a java.io.FileOutputStream(), so I assume you tried and verified this :)

Filip
----- Original Message ----- 
From: <er...@swapsimple.com>
To: "Filip Hanik - Dev" <de...@hanik.com>
Cc: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Monday, November 15, 2004 3:16 PM
Subject: Re: Rotating catalina.out with Webmin


On Mon, Nov 15, 2004 at 02:36:57PM -0600, Filip Hanik - Dev wrote:
> nope, the moment you execute the mv the file handle has moved. switch to cronolog to save you some time,
> cronolog might recreate the file for you to, so no handle is ever lost, try it before you come back to the list :)
> 
[...snip...]
> if you dont get webmin fixed, I recommend cronolog instead.
> You cant just rotate it, cause then tomcat loses the file handle, and you
> will lose all further output.

This is incorrect.  A reference to an open file stays perfectly valid
regardless of what is done to the name of the file.  You can even remove
the file entirely and any previously opened file handle will continue to
function (and take up disk space!).

Renaming a file changes the way you get access to the underlying
file object but does not change the object itself.  Since a file handle
that a process has refers to the the underlying object, not the name,
output will continue to be written to the original file and the new
catalina.out will remain empty.

eric

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Rotating catalina.out with Webmin

Posted by er...@swapsimple.com.
On Mon, Nov 15, 2004 at 02:36:57PM -0600, Filip Hanik - Dev wrote:
> nope, the moment you execute the mv the file handle has moved. switch to cronolog to save you some time,
> cronolog might recreate the file for you to, so no handle is ever lost, try it before you come back to the list :)
> 
[...snip...]
> if you dont get webmin fixed, I recommend cronolog instead.
> You cant just rotate it, cause then tomcat loses the file handle, and you
> will lose all further output.

	This is incorrect.  A reference to an open file stays perfectly valid
regardless of what is done to the name of the file.  You can even remove
the file entirely and any previously opened file handle will continue to
function (and take up disk space!).

	Renaming a file changes the way you get access to the underlying
file object but does not change the object itself.  Since a file handle
that a process has refers to the the underlying object, not the name,
output will continue to be written to the original file and the new
catalina.out will remain empty.

eric

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Rotating catalina.out with Webmin

Posted by Filip Hanik - Dev <de...@hanik.com>.
nope, the moment you execute the mv the file handle has moved. switch to cronolog to save you some time,
cronolog might recreate the file for you to, so no handle is ever lost, try it before you come back to the list :)


Filip

----- Original Message ----- 
From: "Carlos Oliva" <ca...@pbsinet.com>
To: "'Tomcat Users List'" <to...@jakarta.apache.org>
Sent: Monday, November 15, 2004 2:28 PM
Subject: RE: Rotating catalina.out with Webmin


Hi Filip,
I set-up the Webmin Log Rotation entry to the following:
1) Re-create log file after rotation? Yes, with mode  and owned by user
and group
   
2) Store old rotated logs in Directory   
Same directory as log file
Default (Same directory as log file)
  
3) Extension for rotated filenames  Default

Should not this maintain the file handle?

-----Original Message-----
From: Filip Hanik - Dev [mailto:devlists@hanik.com] 
Sent: Monday, November 15, 2004 3:19 PM
To: Tomcat Users List
Subject: Re: Rotating catalina.out with Webmin

if you dont get webmin fixed, I recommend cronolog instead.
You cant just rotate it, cause then tomcat loses the file handle, and you
will lose all further output.

with cronolog you simply pipe it through cronolog like this


<your java start command> | /usr/local/sbin/cronolog
"$CATALINA_BASE$"/logs/%Y-%m-%d.catalina.out >> /dev/null 2>&1 

this will rotate the logs daily

Filip

----- Original Message ----- 
From: "Carlos" <Ca...@pbsinet.com>
To: <to...@jakarta.apache.org>
Sent: Monday, November 15, 2004 2:05 PM
Subject: Rotating catalina.out with Webmin


Hi Forum,

 

Could someone recommend settings for using the log rotation of Webmin in
order to rotate catalina.out (any cautionary measures)?  I just created an
entry in Webmin to rotate the catalina.out file weekly with all the default
settings (keeping the last four copies).  Are there any scripts I should run
before or after the rotation is carried out?



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Rotating catalina.out with Webmin

Posted by Carlos Oliva <ca...@pbsinet.com>.
Hi Filip,
I set-up the Webmin Log Rotation entry to the following:
1) Re-create log file after rotation? Yes, with mode  and owned by user
and group
   
2) Store old rotated logs in Directory   
Same directory as log file
Default (Same directory as log file)
  
3) Extension for rotated filenames  Default

Should not this maintain the file handle?

-----Original Message-----
From: Filip Hanik - Dev [mailto:devlists@hanik.com] 
Sent: Monday, November 15, 2004 3:19 PM
To: Tomcat Users List
Subject: Re: Rotating catalina.out with Webmin

if you dont get webmin fixed, I recommend cronolog instead.
You cant just rotate it, cause then tomcat loses the file handle, and you
will lose all further output.

with cronolog you simply pipe it through cronolog like this


<your java start command> | /usr/local/sbin/cronolog
"$CATALINA_BASE$"/logs/%Y-%m-%d.catalina.out >> /dev/null 2>&1 

this will rotate the logs daily

Filip

----- Original Message ----- 
From: "Carlos" <Ca...@pbsinet.com>
To: <to...@jakarta.apache.org>
Sent: Monday, November 15, 2004 2:05 PM
Subject: Rotating catalina.out with Webmin


Hi Forum,

 

Could someone recommend settings for using the log rotation of Webmin in
order to rotate catalina.out (any cautionary measures)?  I just created an
entry in Webmin to rotate the catalina.out file weekly with all the default
settings (keeping the last four copies).  Are there any scripts I should run
before or after the rotation is carried out?



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Rotating catalina.out with Webmin

Posted by Filip Hanik - Dev <de...@hanik.com>.
if you dont get webmin fixed, I recommend cronolog instead.
You cant just rotate it, cause then tomcat loses the file handle, and you will lose all further output.

with cronolog you simply pipe it through cronolog like this


<your java start command> | /usr/local/sbin/cronolog "$CATALINA_BASE$"/logs/%Y-%m-%d.catalina.out >> /dev/null 2>&1 

this will rotate the logs daily

Filip

----- Original Message ----- 
From: "Carlos" <Ca...@pbsinet.com>
To: <to...@jakarta.apache.org>
Sent: Monday, November 15, 2004 2:05 PM
Subject: Rotating catalina.out with Webmin


Hi Forum,

 

Could someone recommend settings for using the log rotation of Webmin in
order to rotate catalina.out (any cautionary measures)?  I just created an
entry in Webmin to rotate the catalina.out file weekly with all the default
settings (keeping the last four copies).  Are there any scripts I should run
before or after the rotation is carried out?



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org