0

I have a systemd timer:

[Unit]
Description=My timer
Wants=network-online.target
After=network-online.target

[Timer]
OnBootSec=10min
OnUnitInactiveSec=10min

[Install]
WantedBy=timers.target

And a corresponding service:

[Unit]
Description=My service

[Service]
Type=simple
ExecStart=/usr/bin/my-script.sh

Which runs every 10 minutes with no problems but it also runs immediately after the system has started whereas I expected the OnBootSec command to delay it for 10 minutes. What am I misunderstanding? This is on Ubuntu 16.04.

2
  • Shouldn't you have [Install] WantedBy=mytimer.target at the end of your unit file for your service?!
    – 13dimitar
    May 30, 2017 at 7:22
  • Apparently not as it works... Isn't it implicit as long as the service and timer files have the same name?
    – lane
    May 30, 2017 at 7:24

1 Answer 1

0

My bad - I had another service wanting this one. Changing that dependency to the timer fixed the problem. Ooops...

Update: The timer was working just fine. The service was being triggered because it was listed as a Wants dependency by another service. Changing that service to Want the timer instead fixed the problem.

1
  • Please update this in your questions, do not put is as answer. Or clarify in the answer what service and so on May 30, 2017 at 8:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .