Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clarifications on Tomcat's "temp" and "work" directories

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?

like image 452
balteo Avatar asked Jan 13 '12 15:01

balteo


People also ask

Is it safe to delete Tomcat temp directory?

Yes, the tomcat/temp directory is safe to delete when the server is stopped.

What is the use of work folder in Tomcat?

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.

What is temp folder in Tomcat?

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.

Where is Tomcat work directory?

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.


1 Answers

  • 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).

like image 181
Robert Avatar answered Oct 06 '22 07:10

Robert