I have several jobs, which I want systemd to start periodically but with an offset to each other.

Since the jobs are quite similar, I want to cover all of them with a single systemd template unit.

However, since the jobs might cause each some load, I want to disentangle the start times and use different systemd timers for each actual service.

Is there a way to hand over additional arguments (as a specific start time) during creating a service based on the template?

systemctl start MyGeneralService@Specific1.{AdditionalArgument??}.service

or is there a way to read a variable later to be used from within the unit template

MyVar = {?XYZ?} /etc/MyService.d/%i.conf {?XYZ?}


or is there any way to define dependencies in a template for derived services? I.e., Before=/After= of derived services in a dynamic(??) way


May I necropost here? :)

You need a timer, that one can create a bunch of for one service by specifying Unit. E.g:

# systemctl edit --full --force MyGeneralService-1w@.timer
OnActiveSec=5 #start on timer activation after 5 sec once 
OnUnitActiveSec=1w #start on timer activation each 1 week pass

If you want more generic (an dirty) way, you can pass 2nd arg by utilizing a %j token:

  1. Create a generic service/timer.
  2. Make hardlinks to that service/timer with desired argument as last prefix word, delimited by -


# systemctl edit --full --force MyGeneralService@.timer

# ln /etc/systemd/system/MyGeneralService@.timer /etc/systemd/system/MyGeneralService-1w@.timer
# ln /etc/systemd/system/MyGeneralService@.timer /etc/systemd/system/MyGeneralService-1d@.timer
# systemctl daemon-reload
# systemctl show MyGeneralService-1w@foo.timer
TimersMonotonic={ OnUnitActiveUSec=1w ; next_elapse=0 }
# systemctl show MyGeneralService-1d@bar.timer
TimersMonotonic={ OnUnitActiveUSec=1d ; next_elapse=0 }

PS: Quick timers hands-on by Arch

  • uh, hardlinks are quite a nice hack - I like that ;) – THX Mar 5 '19 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.