method 1 -Split stream
Use cronolog tool slicing tomcat cronolog a small tool for log slicing whose home page is in http://cronolog.org/ , we can also use it to slice apache .
This method is recommended as follows
Google a bit first. cronolog-1.6.2.tar.gz
1. Download cronolog-1.6.2.tar.gz
2. Installation
# tar ZXVF cronolog-1.6.2.tar.gz
# cronolog-1.6.2/configure
# make
# make Install
Get!
The default is installed under/usr/local/sbin/.
3. Configuration
That's the point.!!!
Found in tomcat/bin/catalian.sh
Org.apache.catalina.startup.Bootstrap "[email protected]" start \ >> "$CATALINA _base"/logs/catalina.out 2&1 &
Change the contents of the above to:
Org.apache.catalina.startup.Bootstrap "[email protected]" start \
|/usr/local/sbin/cronolog "$CATALINA _base"/logs/catalina.%y-%m-%d.out >>/dev/null 2>&1 &
It's changed. Restart
#./catalina.sh start
Now go and see the fruits of labor.
# ls/tomcat/logs/
You'll find a few more files like Catalina.2006.06.01.log under the logs.
Method 2-Script flow
It's just a matter of big file handling, a powerfulBashto take care of;
UseCronDaily to back up the currentCatalina.out, and then emptied his contents;
The reference script is as follows:
#!/bin/sh
y= ' date ' +%y "'
m= ' date ' +%m "'
d= ' date ' +%d "'
Cd/path/tomcat/logs
CP catalina.out catalina.out. $y $m$d
Echo
> Catalina.out
Exit
AttentionLinuxSystem ofCronWhether the service is started, is working properly, and where the script is stored (reason temporarily confidential)
Method 3-Wretched stream
Open itbinUnder the directorycatalina.shDocument, after all, is just aBashFile
Find out,Catalina.outA total of three occurrences;
Part:
Shift
Touch "$CATALINA _base"/logs/catalina.out
If ["$" = "-security"]; Then
echo "Using Security Manager"
Shift
"$_runjava" $JAVA _opts "$LOGGING _config" $CATALINA _opts \
-djava.endorsed.dirs= "$JAVA _endorsed_dirs"-classpath "$CLASSPATH" \
-djava.security.manager \
-djava.security.policy== "$CATALINA _base"/conf/catalina.policy \
-dcatalina.base= "$CATALINA _base" \
-dcatalina.home= "$CATALINA _home" \
-djava.io.tmpdir= "$CATALINA _tmpdir" \
Org.apache.catalina.startup.Bootstrap "[email protected]" start \
>> "$CATALINA _base"/logs/catalina.out 2>&1 &
if [!-Z "$CATALINA _pid"]; Then
Echo $! > $CATALINA _pid
Fi
else
"$_runjava" $JAVA _opts "$LOGGING _config" $CATALINA _opts \
-djava.endorsed.dirs= "$JAVA _endorsed_dirs"-classpath "$CLASSPATH" \
-dcatalina.base= "$CATALINA _base" \
-dcatalina.home= "$CATALINA _home" \
-djava.io.tmpdir= "$CATALINA _tmpdir" \
Org.apache.catalina.startup.Bootstrap "[email protected]" start \
>> "$CATALINA _base"/logs/catalina.out 2>&1 &
Personally think that's where it's writtenCatalina.outWhat about the other empty devices that he wrote?
Note Before modifying the original filecatalina.shThe backup yo~!!
Modify the code in the above
>> "$CATALINA _base"/logs/catalina.out 2>&1 &
For
>>/dev/null 2>&1 &
Save, and then startTomcat, the currentCatalina.outIt's been empty all the time.
This method is I think of myself, personally think more brave, not yet in the production environment tested. The virtual machine test is passed.
Method 4-flow of people
This method is actuallyLinuxThe system administrator manually remove, manual operation, referred to as "flow";
best to stop before deletingTomcatof services;
The Catalina.out file for Tomcat under Linux is too large, and the directory change resolution