在 Ubuntu 里“定时器”通常指 systemd 的 timer(还有可能是 cron 或 anacron)。下面分别说明。
systemctl list-timers --all
apt-daily.timer 为例)sudo systemctl disable --now apt-daily.timer
disable:开机不再启动--now:立即停止当前运行sudo systemctl stop apt-daily.timer
sudo systemctl mask apt-daily.timer
恢复:
sudo systemctl unmask apt-daily.timer
crontab -l # 查看
crontab -r # 删除当前用户所有任务
或编辑:
crontab -e
注释掉对应行(# 开头)
ls /etc/cron.d/
ls /etc/cron.daily/
直接删或改名:
sudo mv /etc/cron.daily/foo /etc/cron.daily/foo.disabled
sudo systemctl disable --now anacron.timer
或:
sudo apt remove anacron
禁用自动更新定时器:
sudo systemctl disable --now apt-daily.timer
sudo systemctl disable --now apt-daily-upgrade.timer
如果你能告诉我具体是哪个定时器(比如 apt-daily、snap、logrotate 或某个自定义服务),我可以给你更精确的命令。