Systemd-tmpfiles: Difference between revisions
Created page with "systemd-tmpfiles is a systemd subsystem that creates, deletes, and cleans up temporary files and directories on a system. Its main functions are: # Create system directories such as /proc, /sys, /var, /tmp, etc. # Cleanup operations on specific directories such as in /tmp and /var/tmp. == Configuration == To see the current configs, run: <code>systemd-tmpfiles --cat-config</code>. Configuration files are located in the following directories: * Default system config fi..." |
No edit summary |
||
| Line 1: | Line 1: | ||
systemd-tmpfiles is a systemd subsystem that creates, deletes, and cleans up temporary files and directories on a system. Its main functions are: | systemd-tmpfiles is a systemd subsystem that creates, deletes, and cleans up temporary files and directories on a system. Its main functions are: | ||
# Create system directories such as /proc, /sys, /var, /tmp, etc. | # Create system directories such as <code>/proc</code>, <code>/sys</code>, <code>/var</code>, <code>/tmp</code>, etc. | ||
# Cleanup operations on specific directories such as in /tmp and /var/tmp. | # Cleanup operations on specific directories such as in <code>/tmp</code> and <code>/var/tmp</code>. | ||
Directory cleanups are done using a <code>systemd-tmpfiles-clean</code> timer and service. On Red Hat based systems, the cleanup timer runs once 15 minutes after startup and also once a day. | |||
== Configuration == | == Configuration == | ||
Latest revision as of 21:06, 17 April 2023
systemd-tmpfiles is a systemd subsystem that creates, deletes, and cleans up temporary files and directories on a system. Its main functions are:
- Create system directories such as
/proc,/sys,/var,/tmp, etc. - Cleanup operations on specific directories such as in
/tmpand/var/tmp.
Directory cleanups are done using a systemd-tmpfiles-clean timer and service. On Red Hat based systems, the cleanup timer runs once 15 minutes after startup and also once a day.
Configuration
To see the current configs, run: systemd-tmpfiles --cat-config. Configuration files are located in the following directories:
- Default system config files are located in
/usr/lib/tmpfiles.d. - Alternatively:
/run/tmpfiles.d/*.conf - Custom configs can be placed in
/etc/tmpfiles.d. Overrides files with the same names in the other locations listed above.
Custom config
See the tmpfiles.d man page for a comprehensive overview. I will go over some important bits below.
To add your own configuration, place a file with a .conf file extention in /etc/tmpfiles.d/. Each line should contain a single directive for a single path. For example:
#Type Path Mode UID GID Age Argument
d /run/user 0755 root root 10d -
L /tmp/foobar - - - - /dev/null
Types that you may frequently use are listed below:
| Type | Description |
|---|---|
f
|
Create a file if it doesn't exist |
F
|
Create a file or truncate it if it exists |
d
|
Create a directory |
c
|
Create a character device node |
r
|
Removes a file or directory if it exists. Does not follow symlinks. Use 'R' for recursive removes. |
x
|
Exclude a path during a clean operation |
X
|
Exclude a path (to a directory) during a clean operation |
Q
|
Creates a subvolume (or directory if the underlying filesystem doesn't support volumes) |
L
|
Creates a symlink |
!
|
Exclamation mark '!' denotes that the rule should only execute on system startup. |
If an age is specified, automatic cleanup of files older than the specified age will be done. Files older than the specified age will be deleted.