工具: systemd-tmpfiles
配置文件地址:/usr/lib/tmpfiles.d/.conf
/run/tmpfiles.d/.conf
/etc/tmpfiles.d/*.conf
定时器:systemd-tmpfiles-clean.timer
服务: systemd-tmpfiles-clean.service
命令: systemd-tmpfiles -- clean
1.复制配置文件
cp /usr/lib/tmpfiles.d/tmp.conf /etc/tmpfiles.d/tmp.conf
vim /etc/tmpfiles.d/tmp.conf
2.配置文件内容为
q /tmp 1777 root root 5d
3验证命令
systemd-tmpfiles --clean /etc/tmpfiles.d/tmp.conf
4 添加新配置
#创建文件:/etc/tmpfiles.d/momentary.conf
d /run/momentary 0700 root root 30s # /run/momentary目录下,未使用的任何文件必须清除
#验证
systemd-tmpfiles --create /etc/tmpfiles.d/momentary.conf
ls -ld /run/momentary
touch /run/momentary/testfile
#?
systemd-tmpfiles --clean /etc/tmpfiles.d/momentary.conf
ls -l /run/momentary/testfile