Issue description:
On bootup we trigger the service initialization script that is shown below. The script is a part of Instance User Data
.
This script copies the necessary service/timer things to systemd
folder and starts a timer.
From time to time after reboot our timers are not working and stays in N/A
.
The sudo systemctl restart cleanup.timer
command does not help.
Only sudo systemctl stop cleanup.timer
and then sudo systemctl start cleanup.timer
works.
We have this problem not only with a particular timer. We got lot of timers with almost same structure and initialization service. All timers are loaded but some of them can be in active (elapsed)
status and not working.
Our setup:
We run Ubuntu 18.04 LTS
.
We have this service initialization script:
sudo cp <BASIC PATH>/services/cleanup.service /etc/systemd/system/cleanup.service
sudo cp <BASIC PATH>/services/cleanup.timer /etc/systemd/system/cleanup.timer
sudo systemctl daemon-reload
sudo systemctl start cleanup.timer
And this cleanup.service
:
[Unit]
Description=Service to cleanup things
Requires=docker.service
After=docker.service
[Service]
ExecStart=<<SHELL COMMAND>>
And this cleanup.timer
:
[Unit]
Description=Timer for service to cleanup things
[Timer]
OnBootSec=1min
OnUnitActiveSec=1800sec
AccuracySec=5sec
[Install]
WantedBy=timers.target
Now check these commands:
> sudo systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
n/a n/a n/a n/a cleanup.timer cleanup.service
> sudo systemctl status cleanup.timer
● cleanup.timer - Timer for service to cleanup things
Loaded: loaded (/etc/systemd/system/cleanup.timer; disabled; vendor preset: enabled)
Active: active (elapsed) since Wed 2021-11-17 21:07:22 UTC; 11h ago
Trigger: n/a
Nov 17 21:07:22 ip-XX-XX-XX-XX systemd[1]: Started Timer for service to cleanup things.
Question:
What could be the reason of this situation and how to avoid it?