我使用系统的tmp目录来存储临时需要的文件。文件是使用PHP的tmpfilenam()
放置在这里的(不确定这是否相关)。
我的系统如何确定何时应该删除此目录中的文件?创建文件时,会为其名称提供一个随机字符串。这个字符串在确定何时应该删除文件时有意义吗?
有一个脚本每天运行,用于清理/tmp
中的旧文件。/etc/periodic/daily/110.clean-tmps
删除/tmp
中3天内未被访问的所有文件。可以使用/etc/defaults/periodic.conf
:中的设置来控制脚本
# 110.clean-tmps
daily_clean_tmps_enable="YES" # Delete stuff daily
daily_clean_tmps_dirs="/tmp" # Delete under here
daily_clean_tmps_days="3" # If not accessed for
daily_clean_tmps_ignore=".X*-lock .X11-unix .ICE-unix .font-unix .XIM-unix"
daily_clean_tmps_ignore="$daily_clean_tmps_ignore quota.user quota.group"
# Don't delete these
daily_clean_tmps_verbose="YES" # Mention files deleted