Tomcat Server creating Directories in tmp

允我心安 提交于 2021-02-07 05:25:15

问题


Everytime my embedded virtual tomcat server is ran (spring boot) it creates a directory structure in /tmp/ that is named tomcat.##########################.8080 (I am guessing 8080 is for port or something but the 8080 is consistent). This structure does not take up much space alone but after running the tomcat server often over time this can fill up. Can I prevent this from happening as a configurable option?

An example of the path created can look something like: /tmp/tomcat.1185139485157901.8080/work/Tomcat/localhost/_/ SESSIONS.ser WEB-INF/ etc. etc. etc.


回答1:


Unfortunately, both embedded and non-embedded Tomcat needs to have a directory to store temporary files. This is not configurable, however, you can specify the directory in which Tomcat stores these temporary files using setBaseDir.

This should be the first method called public void setBaseDir(String basedir) and if it is not specified in your code it will look for it in

system properties - catalina.base, catalina.home - $HOME/tomcat.$PORT

By knowing the location I recommend writing a simple scheduled script that checks every so often and removes the files under that directory.



来源:https://stackoverflow.com/questions/27865189/tomcat-server-creating-directories-in-tmp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!