RHCSA Rapid Track
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:
/tmpis 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. Onlyrootshould have read and write access to/run/gallifrey.
/tmpis under systemd-tmpfiles control. To override the upstream settings, copy/usr/lib/tmpfiles.d/tmp.confto/etc/tmpfiles.d/.[student@serverX ~]$sudo cp /usr/lib/tmpfiles.d/tmp.conf /etc/tmpfiles.d/
Find the line in
/etc/tmpfiles.d/tmp.confthat controls the purging interval for/tmp, and change the interval from10dto5d.Open
/etc/tmpfiles.d/tmp.confin 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.confCreate a new configuration file
/etc/tmpfiles.d/gallifrey.confwith 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/gallifreydirectory.Create a new file under
/run/gallifrey.[student@serverX ~]$sudo touch /run/gallifrey/companionWait for at least 30 seconds.
[student@serverX ~]$sleep 30sHave systemd-tmpfiles clean the
/run/gallifreydirectory.[student@serverX ~]$sudo systemd-tmpfiles --clean gallifrey.confInspect the contents of
/run/gallifrey.[student@serverX ~]$sudo ls -l /run/gallifrey