I have been using Tomcat for quite a while now but I am not sure what the
- "temp" and
- "work"
directories are used for and when I need to clean which.
Can anyone please advise?
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?
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).
Addressing the temp files not being cleaned after restart.
<Host name="localhost" appBase="webapps">
<Context docBase="mywebapp" path="/mywebapp">
<LifecycleListener className="org.apache.catalina.startup.ContextConfig"
<Parameter name="clearReferencesStopThreads" value="true" />
</LifecycleListener>
</Context>
</Host>
The configuration you added to the server.xml file will enable Tomcat's cleanup mechanism to remove temporary files in the /opt/tomcat/temp directory. This is a valid way to address the issue of accumulated temporary files.This solved the issue for me. Make sure it is affecting your desired webapp.
Also can someone please specify the possible reasons why these files are not getting cleaned? I am facing the same issue where temp files are not being cleaned up after tomcat restart. I am trying to find the solution other than adding the configuration.
© 2022 - 2024 — McMap. All rights reserved.