legacy-knowledge-base
公開されました Sep. 10, 2025

Managing Temp Files in Tomcat

written-by

Madhusudan Sharma

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

Issue

  • How temp files in Tomcat are handled? Do they get deleted automatically after the file upload is successful?

Environment

  • Liferay DXP 7.4

Resolution

  • Temporary Files During Upload – Documents and Media:
    1. When files are uploaded via the Documents and Media portlet in Liferay, they are first placed into a temporary location, typically the tomcat/temp directory. This is a standard step in the upload process.
    2. During the upload, two temporary files are generated:
    • One with a unique identifier and no extension
    • Another prefixed with upload_ and containing the original file extension
    3. The Document and Media Library implements a method (deleteExpiredTemporaryFileEntries) and has a scheduled job for deleting temporary file entries.
    4. To view or adjust this behavior, you can navigate to:
    • Control Panel > Configuration > System Settings > Documents and Media > Service
    • Look for the setting: Temporary File Entries Check Interval
    • By default, it is set to 1, meaning the system will check every hour to remove expired temporary files (based on certain criteria).
    5. Therefore, under normal circumstances, these temporary files (related to Documents and Media) should be deleted automatically once the upload is complete or a preview for the same has been generated.
  • In Case Temp Files Persist:
    1. If you notice a large number of temp files accumulating, this could be due to:
    • Failed or interrupted uploads
    • Application server (Tomcat) limitations in handling temp files

    It's important to note that Liferay doesn't directly manage the tomcat/temp directory—this is handled by Tomcat itself.

  • Suggestions to Manage Temp Folder Growth:
  • Check Liferay logs: Look for any upload-related errors that might be preventing cleanup.
  • Scheduled cleanup: You may implement a regular cleanup process to remove stale files, but only after shutting down Tomcat. Deleting files while Tomcat is running can lead to instability or unexpected behavior.
  • Custom temp path: If needed, you can configure a custom temp directory to better isolate and manage these files. Refer to the official article: How do I change Tomcat's temp folder path to another?

 

did-this-article-resolve-your-issue

legacy-knowledge-base