CodexBloom - Programming Q&A Platform

implementing systemd timer not triggering service on Debian 11

πŸ‘€ Views: 61 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-23
systemd debian timer bash

I recently switched to I'm maintaining legacy code that I'm collaborating on a project where I'm prototyping a solution and I'm stuck on something that should probably be simple. I'm having trouble with a systemd timer that isn't triggering the associated service as expected on my Debian 11 server. I've created a timer unit that is supposed to run a script every 5 minutes, but it seems to be failing silently. Here’s what I have: My timer unit file is located at `/etc/systemd/system/my-script.timer`: ```ini [Unit] Description=Runs my script every 5 minutes [Timer] OnCalendar=*:0/5 Unit=my-script.service [Install] WantedBy=timers.target ``` And my service unit file is at `/etc/systemd/system/my-script.service`: ```ini [Unit] Description=My script service [Service] Type=simple ExecStart=/usr/local/bin/my-script.sh ``` I've made sure to enable the timer using `systemctl enable my-script.timer` and started it with `systemctl start my-script.timer`. However, when I check the status with `systemctl status my-script.timer`, I see that it's loaded but not triggering the service: ``` ● my-script.timer - Runs my script every 5 minutes Loaded: loaded (/etc/systemd/system/my-script.timer; enabled; vendor preset: enabled) Active: active (waiting) since Fri 2023-10-27 10:00:00 UTC; 5min ago ``` I also looked at the journal logs with `journalctl -u my-script.timer` and found this: ``` Oct 27 10:00:00 debian11 systemd[1]: my-script.timer: Adding 5min 0s random left in random sleep. ``` The script itself is quite simple and runs fine when executed manually: ```bash #!/bin/bash echo "Hello, world!" >> /var/log/my-script.log ``` I verified that the script has execute permissions with `chmod +x /usr/local/bin/my-script.sh`. Can anyone suggest what might be going wrong or what I could check to troubleshoot this scenario further? I’ve double-checked the timer syntax, and everything seems correct, but I'm just not getting any output from it. Thanks in advance for your help! How would you solve this? I'm on Debian using the latest version of Bash. I appreciate any insights! Any help would be greatly appreciated! What am I doing wrong? My development environment is Windows 11.