Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

How to Keep Files in /tmp or /run from Being Deleted by systemd-tmpfiles

A scoped systemd-tmpfiles X rule can exclude an application subtree in /tmp from cleanup. For reboot-persistent data, choose /var/tmp or application storage—not /run.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For one application directory in /tmp, add a narrowly scoped X rule in /etc/tmpfiles.d/ to exclude that subtree from age-based cleanup, then review the configuration and run a dry run. If files must survive a reboot, do not try to preserve them in /run: move them to /var/tmp or the application’s persistent state location instead.

First decide how long the files need to last

The right fix depends on whether the files are disposable temporary data, runtime state for this boot, or data the application must retain. The Filesystem Hierarchy Standard (FHS) distinguishes these locations by purpose:

As an Amazon Associate I earn from qualifying purchases.

Location Intended lifetime Practical implication
/tmp Temporary files. Programs must not assume files survive between invocations. The FHS recommends clearing its contents at boot, but this is a recommendation, not a requirement. Use an exclusion only when temporary data genuinely needs protection from a cleanup rule on this system. FHS: /tmp
/run System information and runtime state since boot; it must be cleared at the beginning of boot. Do not use it for data that must survive reboot. FHS: /run
/var/tmp Temporary files intended to be preserved between reboots; the FHS says they must not be deleted at boot. Prefer it when the data is temporary but needs to outlast a reboot. FHS: /var/tmp
Application-specific persistent storage Non-temporary application state. Use the location appropriate to the application and system layout rather than making a temporary directory permanent.

These FHS lifecycle rules describe the directories’ purposes; they do not prove that a particular distribution deletes files using a particular systemd-tmpfiles rule. Check the affected host’s configuration before changing it.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How systemd-tmpfiles decides what to clean

systemd-tmpfiles creates, removes, and cleans paths according to tmpfiles.d configuration. Age-based cleanup applies to entries with an age parameter; there is no universal cleanup interval to assume. The active rule depends on the installed distribution and its local configuration. See the systemd-tmpfiles manual and the tmpfiles.d manual, and check the versions installed on the machine.

The x rule type ignores one path during cleaning; X ignores a path recursively. For an application subtree, X is the documented type to consider. A representative line is:

X /tmp/my-application - - - -

Replace /tmp/my-application with the exact directory. Confirm the fields and rule behavior against the local tmpfiles.d(5) manual and the other rules present on the host before relying on it.

Add a targeted exclusion for a /tmp subtree

  1. Identify the exact path and when it disappears. Determine whether deletion happens during boot or periodic cleanup. Confirm that the files are genuinely temporary and that preserving them in /tmp is the intended design.
  2. Find the rule that affects it. Inspect the host’s tmpfiles configuration and identify the relevant vendor rule or local configuration. Vendor files and overrides vary by distribution.
  3. Create an administrator-owned rule. Put a narrowly scoped exclusion in a file under /etc/tmpfiles.d/, using a name that does not unintentionally replace a vendor file. For example, a file named /etc/tmpfiles.d/my-application.conf could contain the representative X line above. Follow the local manual for supported syntax and rule ordering.
  4. Review the prospective cleanup without deleting files. Use systemd-tmpfiles --clean --dry-run to inspect prospective operations. The exact command options and output can depend on the installed systemd version; consult the local manual.
  5. Apply the change according to the local manual. The systemd-tmpfiles manual says to restart systemd-tmpfiles-clean.service after changing cleanup configuration so settings that can safely take effect at runtime are applied. Verify service behavior on the installed system before doing so.

A recursive exclusion protects the selected subtree from cleanup; keep its scope as small as the application allows. Avoid changing broader cleanup policy when a path-specific rule addresses the problem.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When a vendor cleanup file needs to be disabled

Administrator configuration in /etc/tmpfiles.d/ takes precedence over a file in /usr/lib/tmpfiles.d/ or /run/tmpfiles.d/ when the filenames match. The documented way to disable an entire vendor-supplied configuration file is to create a same-name symlink under /etc/tmpfiles.d/ pointing to /dev/null. That disables the whole file, not just one path, and may affect other cleanup entries. Prefer a targeted exclusion when it is sufficient.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why an exclusion cannot make /run survive reboot

/run is for runtime information describing the system since it booted, and the FHS requires it to be cleared at boot. A cleanup exclusion is not a sound way to turn it into persistent storage. Put reboot-persistent temporary files in /var/tmp; put non-temporary application state in the application’s persistent location.

Troubleshoot a deletion without guessing

  • Pin down the lifecycle: record the exact path and whether the loss occurs at boot or later.
  • Inspect the installed configuration: vendor rules and local overrides are machine-specific; identify the actual rule rather than assuming a default age or schedule.
  • Check local documentation: consult tmpfiles.d(5) for supported rule types and ordering on that system.
  • Use a dry run before applying a cleanup change: review the prospective operations with the documented dry-run option.
  • Reconsider the storage location if reboot survival is required: use /var/tmp for temporary data or application-appropriate persistent storage for retained state.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.