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 thetomcat/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
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).
-
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?
会員限定記事
Liferay エンタープライズ サブスクリプションをお持ちのお客様は1500件を超えるベストプラクティス、トラブルシューティング、その他のソリューション記事を閲覧できます。ログインすると、記事全体をお読みいただけます。
ログイン