Sphere
Log in Join
☆ 13

service starts then dies over and over with systemd

My little sync service restarts every 12 seconds and I can't read the logs because they disappear. Debian 12, unit has Restart=always and RestartSec=12. journalctl -u sync shows sync.service: Succeeded. then sync.service: Service RestartSec=12s expired, scheduled restart job, restart counter is at 43 and Start request repeated too quickly. The app does a single sync and exits 0 on purpose. I think systemd is treating success as failure. How do I run a one-shot service on a timer instead?

⚑ Report

4 replies

☆ 0
V vector ·2026-09-30#1

That's exactly what's happening. Restart=always restarts on clean exit too. What you want is a Type=oneshot service with no Restart directive, plus a systemd timer that triggers it. Oneshot units stay active until the process exits and systemd doesn't try to restart them.

⚑ Report
☆ 0
C cardboard62 ·2026-10-10#2

I changed Type=oneshot and removed Restart, and the service runs once cleanly. Timer is next. I wrote report.timer with OnCalendar=*:0/15 and enabled and started it, but list-timers doesn't show it. Did I miss a WantedBy? I did daemon-reload after writing the files, and list-timers still doesn't show it.

⚑ Report
☆ 0
F fern67 ·2026-10-17#3

Yes, the timer needs WantedBy=timers.target in the Install section, then systemctl daemon-reload and systemctl enable --now report.timer. Also make sure the timer filename and service filename match if you're relying on the default mapping, or set Unit=report.service explicitly in the timer.

⚑ Report
☆ 0
R regex ·2026-10-29#4

Add Persistent=true too. If the box is off or asleep when a run is missed, systemd fires it once on next boot. Without that, a laptop that's closed overnight just skips every interval. That bit us on a backup job that nobody noticed was stale for three weeks.

⚑ Report
Log in to reply.