I couldn't restart Tomcat webserver. But catalina.out get very big. I have tried delete on test server and created new empty. But Tomcat doesn't write anymore in new catalina.out. How correct delete/create empty new one ?

- 5,753
- 72
- 57
- 129

- 23,228
- 58
- 149
- 207
-
you don't need to create one. it will be automatically created. perhaps you've created with `root` or another user which leads tomcat to not open it. – Mustafa Genç Feb 13 '14 at 12:32
4 Answers
If you are using Gnu/Linux or Mac OS X, you can just do:
echo "" > catalina.out
or even shorter:
> catalina.out

- 2,833
- 3
- 27
- 41
-
1as @Mustafa Genç said, you might have created the file as `root`? if so, delete it, don't recreate it, let tomcat create it automatically. – Sergo Pasoevi Feb 13 '14 at 12:44
-
7Important thing - don't delete never!!! Because program keeps file descriptor. File should be truncated as is suggested in this answer – user710818 Feb 13 '14 at 12:56
for me
echo "" > catalina.out
or
sudo echo "" > catalina.out
didn't work, as the file was created with root/other user privilege
sudo truncate -s 0 catalina.out
worked for me. here -s is for size and I am setting the file size to 0

- 390
- 1
- 4
- 15
In base Tomcat installs, catalina.out
is usually the result of stdout/stderr redirections via the Tomcat launcher script.
If you run Tomcat on a Unix system, and if you delete the file while Tomcat is running, the problem is that the process will still have a descriptor open to that file and continue to write on it. The solution is therefore to use a program dedicated to handling such cases. For instance, logrotate (which is standard in pretty much all Linux distributions).

- 119,121
- 33
- 254
- 329
When tomcat
server is used, it is pretty normal that the disk usage increases as logs accumulate in the catalina.out
file.
If the catalina.out
is deleted after tomcat
is stopped, it will create a new catalina.out
once tomcat
starts and writes to it. But in your case, since catalina.out
was deleted while tomcat
was running it is holding up the file reference and writing to the deleted file. You can get rid of this by restarting the tomcat
server.
Actually you can clear the log of catalina.out
file without stopping tomcat with the command below.
sudo cat /dev/null > /opt/tomcat/apache-tomcat-9.0.37/logs/catalina.out
To keep catalina.out
smaller and backup older logs, either one of the following ways can be used:
You could use the above
Linux
command and add it to aCronScheduler
to run daily/ weekly/ monthly or yearly as preferred.Use
logrotate
tool inLinux
. It is a log managing command-line tool in Linux. This can rotate the log files under different conditions. Particularly, we can rotate log files on a fixed duration or if the file has grown to a certain size. You can click here for more info on this.

- 11,530
- 2
- 71
- 51