Temp Files Flashcards
Which service manages the lifecyle of temp files
systemd-tempfiles-setup
What does systemd-tmpfiles-setup service do?
create, delete, and clean up volatile and temporary files and directories.
where is the config that systemd uses to manage systemd-tmpfiles-setup service located?
/usr/lib/systemd/system/systemd-tmpfiles-setup.service
Diff between:
/usr/lib/systemd/system/systemd-tmfiles-setup.services
and files in
/usr/lib/tmpfiles.d/, /run/tmpfiles.d/, /etc/tmpfiles.d/
First is a config file for systemd telling it how to start and manage systemd-tmpfiles-setup
The second set of files are config files for systemd-tmpfiles-setup.
What are location of config files for systemd-tmpfiles-setup:
1) /usr/lib/tmpfiles.d/
2) /run/tmpfiles.d/
3) /etc/tmpfiles.d/
In what order are systemd-tmpfiles.setup config files evaluated?
1) /usr/lib/tmpfiles.d/.conf
2) /run/tmpfiles.d/.conf
3) /etc/tmpfiles.d/*.conf
Explain tmp file cleanup process
timer unit
systemd-tmpfiles-clean.timer
periodically call
systemd-tmpfiles-clean.service
to do the cleaup as per configurations in:
1) /usr/lib/tmpfiles.d/
2) /etc/tmpfiles.d/
3) /run/tmpfiles.d/
What are the different systemd unit types?
1) Service Units
2) Socket Units
3) Device Units
4) Mount Units
5) Automount Units
6) Target Units (.target):
7) Timer Units (.timer):
8) Path Units (.path):
9) Slice Units (.slice):
10) Scope Units (.scope):
Explain:
q /tmp 1777 root root 10d
tmpfile config of /usr/lib/tmfiles.d/tmp.conf
says that files under /tmp will be purged after 10d if not accessed.
How do you modify the content of
/usr/lib/tmfiles.d/tmp.conf
1) Copy it to following location and modify the copy. Then run the clean command.
/etc/tmfiles.d/tmp.conf
systemd-tmpfiles --clean etc/tmfiles.d/tmp.conf
Create a new folder and define its cleanup policy
echo 'q /home/student/momentary 0700 root root 30s' > /etc/tmpfiles.d/momentary.conf
systemd-tmpfiles --create /etc/tmp files.d/momentary.conf
What is special about the /run folder
exists only in memory
What command does systemd-tmpfiles-setup calls to do its job?
systemd-tmpfiles
Show the content of a timer unit
systemctl cat systemd-tmpfiles-clean.timer
How does a timer know when to invoke the service it is meant to invoke?
In the config file of the timer, there is a [Timer] section for this purpose