0

I have a systemd template, load@.service defined as:

[Unit]
Description=load script
Wants=network-online.target
After=network-online.target
PartOf=load.target

[Service]
Type=simple
ExecStart=/usr/bin/python3 load -d %i
User=root

[Install]
WantedBy=default.target

I need to run four different instances of this script with different parameters for -d, so I have set up a load.target defined as:

[Unit]
Description=dataloader.load workers
Wants=load@1.service load@2.service load@3.service load@4.service

[Install]
WantedBy=multi-user.target

I want each of the four instances to run every 10 minutes.

How can I set up a systemd timer to invoke the .target at an interval?

0

You can create a timer unit load@.timer defined as:

[Unit]
Description=Run load@.service every 10 minutes

[Timer]
OnCalendar=*:0/10
AccuracySec=1us

And modify load.target to invoke the .timer units instead of the .service units:

[Unit]
Description=dataloader.load workers
Wants=load@1.timer load@2.timer load@3.timer load@4.timer

[Install]
WantedBy=multi-user.target

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.