在 Ubuntu 中,“定时器”通常指 systemd 的 timer(类似 cron 的现代化方案),也可能指 cron 服务。下面分别说明。
systemctl list-timers
systemctl status your-task.timer
sudo systemctl restart your-task.timer
sudo systemctl stop your-task.timer
sudo systemctl start your-task.timer
sudo systemctl daemon-reload
sudo systemctl restart your-task.timer
sudo systemctl enable your-task.timer
sudo systemctl restart cron
systemctl status cron
crontab -e # 当前用户
sudo crontab -e # root 用户
restart cron.timer(不存在)restart cron(服务名)restart xxx.timer(systemd timer)假设你有一个:
/etc/systemd/system/backup.timer
/etc/systemd/system/backup.service
重启方式:
sudo systemctl daemon-reload
sudo systemctl restart backup.timer
如果你能告诉我:
我可以给你更精确的命令。