自定义 Debian 清理策略
一 策略框架与频率建议
二 核心清理项与推荐做法
三 自动化与定时执行
[Unit]
Description=Custom system cleanup
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/cleanup.sh
[Unit]
Description=Run cleanup daily
Requires=cleanup.service
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
sudo systemctl enable --now cleanup.timer
systemctl list-timers | grep cleanup
0 3 * * * /usr/bin/find /tmp -type f -atime +7 -delete
0 2 * * 0 /usr/bin/journalctl --vacuum-time=7d
四 关键配置文件与位置
五 安全与验证