CodexBloom - Programming Q&A Platform

Ubuntu 22.04 - guide with Custom Systemd Timer Not Triggering Scheduled Service

๐Ÿ‘€ Views: 463 ๐Ÿ’ฌ Answers: 1 ๐Ÿ“… Created: 2025-06-10
systemd ubuntu timer bash

I've encountered a strange issue with I'm having trouble with I'm having trouble with a custom systemd timer that I set up on my Ubuntu 22.04 server. The timer is supposed to trigger a service every hour, but it seems to be completely inactive. I created a timer unit file named `my_service.timer` and a corresponding service unit file `my_service.service`. Hereโ€™s what I've configured: **my_service.service**: ```ini [Unit] Description=My Custom Service [Service] Type=simple ExecStart=/usr/local/bin/my_script.sh ``` **my_service.timer**: ```ini [Unit] Description=Run My Custom Service every hour [Timer] OnCalendar=*:0/60 Persistent=true [Install] WantedBy=timers.target ``` After creating these files, I ran the following commands to enable and start the timer: ```bash sudo systemctl daemon-reload sudo systemctl enable my_service.timer sudo systemctl start my_service.timer ``` However, when I check the status of the timer using `systemctl status my_service.timer`, it shows that it's loaded but doesn't seem to have triggered the service at all. The logs from `journalctl -u my_service.timer` don't indicate any errors, but there's also no record of any execution. Iโ€™ve tried checking the timer with `systemctl list-timers --all`, and it shows that the next due time is indicated correctly, but nothing happens when that time arrives. To troubleshoot, I've also added logging to `my_script.sh`, and it still doesnโ€™t write anything to the log file. Iโ€™ve double-checked permissions, and the script is executable by the user that the service runs as. Is there something I might be missing in my timer configuration or service setup? Any help would be greatly appreciated! I'm on macOS using the latest version of Bash. Thanks, I really appreciate it!