If systemd-tmpfiles is not removing old files, first confirm that cleanup—not creation or removal—was actually run. Then check whether a matching rule has an age, whether the relevant timestamps exceed that age, and whether an exclusion, file lock, permission issue, or boot-time option is preventing cleanup. The systemd manuals describe the general behavior, but installed rules and unit overrides can change what happens on a particular distribution.
1. Confirm that the cleanup operation ran
Run systemd-tmpfiles --clean in the context that owns the files. --clean evaluates configured age rules. --create and --remove are separate operations, so a successful create run does not show that stale files were checked. System and user configuration are separate scopes; system cleanup does not read user configuration. See the systemd-tmpfiles manual.
As an Amazon Associate I earn from qualifying purchases.
For more detail while diagnosing, run the command with increased log verbosity and check its output, exit status, and system logs. The manual distinguishes invalid-configuration errors from operational failures. If you changed system rules, restart systemd-tmpfiles-clean.service to apply settings that can safely run at runtime.
2. Verify that a matching rule is eligible for age cleanup
Inspect the actual tmpfiles.d configuration that applies to the path, including administrator overrides. An age field only enables age-based cleanup on rules whose type supports it: d, D, e, v, q, Q, C, x, or X. A missing age or an age of - means that line has no age-based cleanup. A rule that only creates a directory will not make it eligible unless its type and age specify that behavior. The tmpfiles.d manual documents the rule types and fields.
#1 Best Overall
Look for exclusions
Rules of type x and X exclude matching paths from aging cleanup. Check whether an exclusion matches the file or a parent path before changing it; these rules may be deliberately protecting data.
3. Check the configured age against the timestamps
The age is a threshold, not a promise that a file will be deleted after a fixed number of calendar days regardless of activity. An entry must be older than the current time minus the configured age, using the timestamps selected by the rule. By default, the aging algorithm considers access, modification, and status-change timestamps for files; it ignores status-change time for directories. The age-by option can change which timestamps are considered. Review the tmpfiles.d manual and compare the relevant timestamps with the rule’s age.
Rank #2
The systemd project documents defaults of 10 days for files in /tmp/ and 30 days for files in /var/tmp (file hierarchy documentation). These are documented defaults, not guarantees for every distribution or host: local rules and overrides may differ.
4. Check locks, permissions, and execution context
BSD locks can protect files and directories
During aging cleanup, entries with a shared or exclusive BSD file lock are skipped. If a directory is locked, entries beneath it are skipped too. An application may use this behavior to preserve temporary work while it is active. Identify the process and purpose of a lock before changing the application or removing the protection.
Use the appropriate privileges
The systemd-tmpfiles manual warns that cleanup run as a non-root user can update access times on directories being checked. That can make those directories appear too recent for cleanup. When testing system paths, use the system service or appropriate privileges, and inspect logs and the command’s exit status for permission or execution errors.
5. If manual cleanup works, inspect the timer and service
When a manual --clean run works but automatic cleanup does not, inspect systemd-tmpfiles-clean.timer and systemd-tmpfiles-clean.service on the affected host, as well as their journal entries. Unit overrides and behavior vary by distribution and systemd version, so verify the installed unit contents rather than assuming the upstream defaults. The systemd-tmpfiles manual describes the cleanup service.
Rank #4
Boot-only rules need --boot
A tmpfiles.d line marked with ! is considered only when systemd-tmpfiles is invoked with --boot. Verify that the local boot-time unit actually runs the needed combination of --clean and --boot.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →A July 4, 2022 report from an Arch Linux user running systemd 251 said the listed boot units did not invoke systemd-tmpfiles --clean --boot, while running that command manually did perform cleanup (upstream issue #23848). That report describes one version and system, not current behavior across distributions.
Best Value
6. Apply the narrowest safe fix
- If cleanup never ran, correct the command, service, or schedule so the age-clean operation runs in the intended system or user context.
- If no applicable rule can age-clean the path, correct the rule type, path, or age only after checking which timestamps govern eligibility.
- If an
xorXexclusion is unintended, change it only after confirming the path is safe to clean. - If a process holds a lock, establish whether it is protecting live temporary work before altering its behavior.
- If cleanup is meant to happen only at boot, confirm the installed unit passes both required options for the local systemd version before changing a unit.
Do not use /tmp or /var/tmp for durable storage. The systemd project notes that /tmp is typically backed by tmpfs and flushed on reboot; /var/tmp is intended for temporary data that should persist across a reboot (file hierarchy documentation).
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




