How to clean temporary files in /tmp and /var/tmp/
This document (000021386) is provided subject to the disclaimer at the end of this document.
Environment
Situation
/tmp
or /var/tmp
grows as old files are not removed.
Resolution
To change the behavior and remove files after one day, for example, an administrator can override the configuration by placing a file with the same filename in /etc/tmpfiles.d/
with the same configuration except giving an age argument, in this example, one day (1d):
cat << EOF > /etc/tmpfiles.d/fs-tmp.conf q /tmp 1777 root root 1d EOF
Cause
The default configuration has no cleanup by age set up:
/usr/lib/tmpfiles.d/fs-tmp.conf:q /tmp 1777 root root -
Additional Information
systemctl edit systemd-tmpfiles-setup
for during boot, or systemctl edit systemd-tmpfiles-clean
for daily cleanup:
[Service] Environment="SYSTEMD_LOG_LEVEL=debug"
The service systemd-tmpfiles-setup
runs during boot. The service systemd-tmpfiles-clean
runs by the timer systemd-tmpfiles-clean.timer
.
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000021386
- Creation Date: 05-Mar-2024
- Modified Date:14-Mar-2024
-
- SUSE Linux Enterprise Server
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com