可以的,Ubuntu 可以自动清理文件,常见方式如下,你可以按需求选择:
apt 自动清理Ubuntu 会缓存安装包,可定期自动清理:
sudo apt autoremove
sudo apt autoclean
设置自动执行(每周):
sudo systemctl enable apt-daily.timer
systemd 定时清理(最稳妥)例如:自动删除 /tmp 中 7 天前的文件
sudo nano /etc/systemd/system/clean-tmp.service
内容:
[Unit]
Description=Clean /tmp
[Service]
ExecStart=/usr/bin/find /tmp -type f -mtime +7 -delete
再建 timer:
sudo nano /etc/systemd/system/clean-tmp.timer
[Unit]
Description=Run tmp clean weekly
[Timer]
OnCalendar=weekly
Persistent=true
[Install]
WantedBy=timers.target
启用:
sudo systemctl enable --now clean-tmp.timer
cron 自动清理例如每天清理日志:
crontab -e
添加:
0 3 * * * find /var/log -type f -name "*.log" -mtime +30 -delete
bleachbit(图形界面)sudo apt install bleachbit
可设置自动清理缓存、日志、浏览器数据
fslint(重复文件)sudo apt install fslint
~/.cache/tmp/var/log~/.local/share/Trash如果你愿意,可以告诉我:
我可以直接帮你写好配置。