The issue was the script I was trying to run didn't have a bang at the start.
I diagnosed it by:
- looking at the status of the time Andril mentioned above
# systemctl status my.timer
● my.timer - Timer to update stuff
Loaded: loaded (/etc/systemd/system/my.timer; enabled; vendor preset: enabled)
Active: active (elapsed) since Tue 2020-01-28 07:14:54 UTC; 2 weeks 6 days ago
Trigger: n/a
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
- Looking at the list of timers (to get more stats about it)
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
...
n/a n/a Tue 2018-03-20 14:13:46 UTC 1 years 10 months ago my.timer my.service
- Tried running the service to activate the service (as the timer is based on the last time the service was activated
# systemctl status my.service
● my.service - Renew Lets Encrypt certificates
Loaded: loaded (/etc/systemd/system/my.service; static; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2020-02-17 15:53:18 UTC; 20s ago
Process: 19875 ExecStart=/usr/local/sbin/script (code=exited, status=203/EXEC)
Main PID: 19875 (code=exited, status=203/EXEC)
Feb 17 15:53:18 server systemd[1]: Starting Update stuff...
Feb 17 15:53:18 server systemd[19875]: my.service: Failed to execute command: Exec format error
Feb 17 15:53:18 server systemd[19875]: my.service: Failed at step EXEC spawning /usr/local/sbin/script: Exec format error
Feb 17 15:53:18 server systemd[1]: my.service: Main process exited, code=exited, status=203/EXEC
Feb 17 15:53:18 server systemd[1]: my.service: Failed with result 'exit-code'.
Feb 17 15:53:18 server systemd[1]: Failed to start Update stuff.
- By trial and error looked at the script and saw it didn't have a bang, so added one
# vim /usr/local/sbin/script
#!/bin/bash
echo Update!
- Tried running the service again
# systemctl start my.service
# systemctl status letsencrypt.service
● my.service - Update stuff
Loaded: loaded (/etc/systemd/system/my.service; static; vendor preset: enabled)
Active: inactive (dead) since Mon 2020-02-17 16:05:45 UTC; 4s ago
Process: 31781 ExecStart=/usr/local/sbin/script (code=exited, status=0/SUCCESS)
Main PID: 31781 (code=exited, status=0/SUCCESS)
Feb 17 16:05:45 server systemd[1]: Starting Update stuff...
Feb 17 16:05:45 server test[31781]: Update!
Feb 17 16:05:45 server systemd[1]: Started Update stuff.
(woohoo)
- Checked the timers again
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
...
Tue 2020-05-12 16:05:45 UTC 2 months 24 days left Tue 2018-03-20 14:13:46 UTC 1 years 10 months ago my.timer my.service
x timers listed.
Pass --all to see loaded but inactive timers, too.
(now the timer shows that it is going to run again)