CentOS定时器调试步骤如下:
查看定时器状态
systemctl list-timers --all
。systemctl status <定时器名>.timer
。检查配置文件
/etc/systemd/system/*.timer
,确保OnCalendar
等参数正确。systemctl daemon-reload
。查看日志
journalctl -u <定时器名>.timer
。journalctl -u <定时器名>.timer -f
。手动测试
systemctl start <定时器名>.timer
。检查环境与权限
chmod +x /path/to/script.sh
。调整触发频率
OnCalendar
为高频触发(如* * * * *
),快速验证逻辑。参考来源: