I have been using Tomcat for quite a while now but I am not sure what the
directories are used for and when I need to clean which.
Can anyone please advise?
Yes, the tomcat/temp directory is safe to delete when the server is stopped.
The work directory, as its name suggests, is where Tomcat writes any files that it needs during run time, such as the generated servlet code for JSPs, the class files for the same after they are compiled, the serialized sessions during restarts or shutdowns (SESSIONS.
When you startup Tomcat, using startup. bat (Windows) or startup.sh , it calls catalina. bat / catalina.sh respectively. Catalina then needs a temp directory to be set. It does this by setting the CATALINA_TMPDIR variable to TOMCAT_HOME\temp folder and assigns it to java system environment variable as java.
On Windows, the easiest way to go to your Eclipse's Tomcat deployment location is to just right-click on the Tomcat instance in the Servers view and click "Browse Deployment Location..." From there, you can easily browse to the "work" directory as shown below.
work
stores compiled JSPs and other assets.
=> You only need to "clean" the webapp directories under it on the rare occasions when an update to a WebApp is not picked up.
temp
is used to store files created using the Java File API for creating temporary files.
=> You can "clean" it every time you restart Tomcat. If it is getting too full then one of your WebApps may have some form of leak where its not releasing temp files when its done with them (although it could just be under higher load too).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With