In this lab, you will configure your system to purge files older than 5
days from /tmp. You will also add a new temporary
directory called /run/gallifrey to be
automatically created, with files which have been unused for more than
30 seconds being automatically purged.
| Resources | |
|---|---|
| Files: |
|
| Machines: | serverX |
Outcomes:
A new temporary directory called /run/gallifrey,
set up for automatic purging, and a modified purging configuration
for /tmp.
Reset your serverX system.
In production, you have run into a number of issues:
/tmp is running out of disk space. It seems
that allowing files to be unused for 10 days before they are
deleted is too long for your site. You have determined that
deleting files after five days of disuse is acceptable.
Your time-travel research daemon gallifrey
needs a separate temporary directory called
/run/gallifrey. Files in this directory
should be purged automatically after they have been unused for 30
seconds. Only root should have read and write
access to /run/gallifrey.
/tmp is under
systemd-tmpfiles control. To override the upstream
settings, copy /usr/lib/tmpfiles.d/tmp.conf to
/etc/tmpfiles.d/.
[student@serverX ~]$sudo cp /usr/lib/tmpfiles.d/tmp.conf /etc/tmpfiles.d/
Find the line in /etc/tmpfiles.d/tmp.conf that
controls the purging interval for /tmp, and
change the interval from 10d to 5d.
Open /etc/tmpfiles.d/tmp.conf in an editor
and make the change, or:
[student@serverX ~]$sudo sed -i '/^d .tmp /s/10d/5d/' /etc/tmpfiles.d/tmp.conf
Test if systemd-tmpfiles --clean accepts the new configuration.
[student@serverX ~]$sudo systemd-tmpfiles --clean tmp.conf
Create a new configuration file
/etc/tmpfiles.d/gallifrey.conf with the following
content:
# Set up /run/gallifrey, owned by root with 0700 permissions # Files not used for 30 seconds will be automatically deleted d /run/gallifrey 0700 root root 30s
Test your new configuration for creating
/run/gallifrey.
[student@serverX ~]$sudo systemd-tmpfiles --create gallifrey.conf
[student@serverX ~]$ls -ld /run/gallifreydrwx------. 2 root root Feb 19 10:29 /run/gallifrey
Test the purging of your /run/gallifrey
directory.
Create a new file under /run/gallifrey.
[student@serverX ~]$sudo touch /run/gallifrey/companion
Wait for at least 30 seconds.
[student@serverX ~]$sleep 30s
Have systemd-tmpfiles clean the
/run/gallifrey directory.
[student@serverX ~]$sudo systemd-tmpfiles --clean gallifrey.conf
Inspect the contents of /run/gallifrey.
[student@serverX ~]$sudo ls -l /run/gallifrey