在 CentOS 中,通常没有 Windows 那样的“回收站(Recycle Bin)”机制,所以你提到的“recycle 时限”一般出现在以下两种场景中:
如果你是搭建了 Samba 文件共享,并启用了 recycle 模块,可以通过参数设置“保留时间”。
/etc/samba/smb.conf)[shared]
path = /data/shared
read only = no
recycle:repository = .recycle
recycle:keeptree = yes
recycle:versions = yes
recycle:maxsize = 0
recycle:touch = yes
recycle:directory_mode = 0777
recycle:subdir_mode = 0700
Samba 本身 没有直接的过期时间参数,但可以用 cron + find 实现:
# 每天删除 7 天前的回收站文件
find /data/shared/.recycle -type f -mtime +7 -delete
加入 cron:
crontab -e
0 2 * * * find /data/shared/.recycle -type f -mtime +7 -delete
CentOS 可用 trash-cli 模拟回收站。
yum install epel-release -y
yum install trash-cli -y
trash-put file.txt
# 清空 30 天前的回收站
0 3 * * * trash-empty 30
CentOS 使用 systemd-tmpfiles:
vim /etc/tmpfiles.d/tmp.conf
示例(10 天清理):
d /tmp 1777 root root 10d
应用:
systemd-tmpfiles --clean
| 场景 | 是否支持时限 | 实现方式 |
|---|---|---|
| Samba recycle | ❌ 无原生参数 | cron + find |
| trash-cli | ✅ | trash-empty N |
| /tmp 临时文件 | ✅ | systemd-tmpfiles |
如果你能说明 “recycle” 是用在什么环境(Samba / 脚本 / 桌面 / 服务器),我可以给你更精确的配置。