CodexBloom - Programming Q&A Platform

Ubuntu 22.10 - Systemd Timer Not Triggering Script Despite Configuration

πŸ‘€ Views: 34 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-05
ubuntu systemd timers bash

I'm working on a personal project and I'm working on a personal project and I'm working with an scenario with a systemd timer on Ubuntu 22.10 that doesn't seem to trigger the associated service as expected..... I have created a timer to run a script every hour, but it appears that the timer is not firing at all. Here’s the configuration I have: The service file `/etc/systemd/system/my_script.service` looks like this: ```ini [Unit] Description=Run My Script [Service] Type=oneshot ExecStart=/usr/local/bin/myscript.sh ``` And the timer file `/etc/systemd/system/my_script.timer`: ```ini [Unit] Description=Run My Script Hourly [Timer] OnCalendar=*:0/1 Persistent=true [Install] WantedBy=timers.target ``` I have enabled and started the timer using: ```bash sudo systemctl enable my_script.timer sudo systemctl start my_script.timer ``` However, when I check the status of the timer, it shows: ```bash systemctl list-timers --all ``` And I see it listed but with a "Next" time that is always in the past, which makes me believe it's not active. Additionally, when I check the logs with `journalctl -u my_script.service`, there are no entries indicating that the script has ever run. I've tried reloading the systemd manager configuration using `sudo systemctl daemon-reload`, but it hasn't resolved the scenario. I suspect it might be a question with the timer configuration or its interaction with the service file. Any insights on what could be going wrong? I'm working on a API that needs to handle this. What's the best practice here? My development environment is Linux.