在CentOS中设置自动回收机制,可根据回收对象不同选择不同方法:
cron定时任务,通过编辑crontab文件,添加如0 2 * * * find /tmp -type f -mtime +30 -exec rm -f {} \;的命令,每天凌晨2点清理/tmp目录下30天前的文件。也可使用logrotate工具,编辑其配置文件,如/etc/logrotate.d/rsyslog,设置日志轮转、压缩和删除规则。trash-cli管理回收站,可安装该软件包,编辑/etc/trash-cli.conf文件,设置auto_empty参数来指定自动清空时间,或通过编辑crontab文件,添加定时任务来定期执行trash-empty命令。