I have a rather annoying issue with systemd timers and drifting start time. I had an old cron.d script (which executed faithfully once every 10 minutes) that I'm trying to modernize. The problem is that the service it starts runs a while longer than 10 minutes. With cron this was not an issue, I simply had two instances running for a while, but systemd does not work the same.
The timer is as follows:
[Timer] OnCalendar=*:0/10:0 Persistent=false AccuracySec=1s
and from what I understand, this is supposed to run at exactly 08:00:00, 08:10:00, 08:20:00, and so on and so forth. But the associated service it starts runs slightly longer than 10 minutes, and this causes the timer to gradually drift by about 10 seconds per run. Meaning the start times are 08:00:00, 08:10:10, 08:20:20 and so on. Is there any way to force the timer to do exactly as I want?
I've also attempted to make the service to run in the background, unmonitored by systemd, but I have not had much success with this. Tried things like
ExecStart=/bin/sh -c "/run/my/cmd -options &" and with
nohup and putting the whole command in a separate shell script to no avail. The
cmd is not started or dies immediately.
So how can I make my systemd timer behave like the old cron script? My only remaining idea/workaround is to make two timers, set at 20 minute intervals, but that sounds like a really dumb idea..