在 Debian(及大多数 Linux 发行版)里,“定时器”通常指 systemd 的 timer,也可能是 cron。下面分别说明。
.timer 或 .service 文件后如果你修改了 /etc/systemd/system/xxx.timer 或相关 service 文件:
sudo systemctl daemon-reload
然后(如果需要):
sudo systemctl restart xxx.timer
systemctl list-timers
systemctl status xxx.timer
sudo systemctl enable xxx.timer
sudo systemctl disable xxx.timer
crontab -e
保存后即自动生效,不需要手动重载。
/etc/cron.*)一般也自动生效,但可重启服务:
sudo systemctl restart cron
| 场景 | 命令 |
|---|---|
| 改了 systemd timer | systemctl daemon-reload |
| 改了 systemd service | systemctl restart xxx.service |
| 改了 crontab | 直接保存 |
| cron 不生效 | systemctl restart cron |
如果你指的是 某种具体定时器(如 anacron、at、systemd timer 示例),可以贴出配置,我可以直接帮你写正确重载方式。