基于Linux下的临时文件的管理

对临时文件的管理:

[[email protected] cron.d]# cd /usr/lib/tmpfiles.d/  切换路径

[[email protected] tmpfiles.d]# vim westos.conf   

[[email protected] tmpfiles.d]# cat westos.conf

d /mnt/westos 1777 root root 15s                     超过15秒之后的文件会挨个删除

基于Linux下的临时文件的管理

[[email protected] tmpfiles.d]# systemd-tmpfiles --create /usr/lib/tmpfiles.d/*      

[[email protected] tmpfiles.d]# systemd-tmpfiles --clean /usr/lib/tmpfiles.d/*  清除

[[email protected] tmpfiles.d]# mkdir /mnt/westos

[[email protected] tmpfiles.d]# touch /mnt/westos/file       建立文件

[[email protected] tmpfiles.d]# touch /mnt/westos/file1

[[email protected] tmpfiles.d]# systemd-tmpfiles --clean /usr/lib/tmpfiles.d/*  超过时间就会按个删除,如下图所示:

基于Linux下的临时文件的管理

[[email protected] tmpfiles.d]# systemd-tmpfiles --clean /usr/lib/tmpfiles.d/*

基于Linux下的临时文件的管理

[[email protected] tmpfiles.d]# systemd-tmpfiles --clean /usr/lib/tmpfiles.d/*

基于Linux下的临时文件的管理

[[email protected] tmpfiles.d]# systemd-tmpfiles --clean /usr/lib/tmpfiles.d/*

基于Linux下的临时文件的管理