温馨提示×

debian recycle如何定时

小樊
40
2026-09-19 09:50:41
栏目: 智能运维

你这里的 “debian recycle” 我理解可能是指 Debian 系统下的回收站(recycle/bin)清理,常见情况有两种:


一、如果是 文件回收站(如桌面环境 Trash)

Debian 桌面(GNOME / KDE 等)的回收站在:

~/.local/share/Trash/

定时清理回收站(推荐用 cron)

每天凌晨清理 7 天前的文件:

crontab -e

添加:

0 0 * * * find ~/.local/share/Trash -type f -mtime +7 -delete

二、如果是 自建的 recycle 目录(如删文件先移到 /recycle)

例如你把删除的文件移到 /recycle

定时清理 /recycle 中 30 天前的文件

crontab -e
0 2 * * * find /recycle -type f -mtime +30 -delete

三、使用 systemd timer(更现代方式)

如果你不想用 cron:

1. 创建服务

sudo nano /etc/systemd/system/clean-recycle.service
[Unit]
Description=Clean recycle directory

[Service]
Type=oneshot
ExecStart=/usr/bin/find /recycle -type f -mtime +30 -delete

2. 创建定时器

sudo nano /etc/systemd/system/clean-recycle.timer
[Unit]
Description=Daily recycle clean

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target

3. 启用

sudo systemctl enable --now clean-recycle.timer

四、如果你指的是 其他软件(如 Samba recycle、Nextcloud recycle)

可以告诉我:

  • 是 哪个服务
  • 是 服务器还是桌面

我可以给你更精确的定时清理方案。

如果你愿意,也可以直接贴一下你说的 “debian recycle” 是哪里看到的。

0 踩