I have the following systemd myscript.service unit that executes an script:


ExecStart=/usr/local/bin/test.sh -a
ExecStop=/usr/local/bin/test.sh -b


And I want to restart it each minute with the following Systemd myscript.timer unit:

Description=Schedule script execution



It only works the first time, after it, the status remains in n/a:

# systemctl list-timers
NEXT                         LEFT        LAST                         PASSED      UNIT                         ACTIVATES
n/a                          n/a         Tue 2019-10-15 14:50:01 EDT  3ms ago     myscript.timer               myscript.service


1 Answer 1


If a .service unit will be executed from a .timer unit, it can't have RemainAfterExit=true. The systemd documentation mentions that:

Note that in case the unit to activate is already active at the time the timer elapses it is not restarted, but simply left running. There is no concept of spawning new service instances in this case. Due to this, services with RemainAfterExit= set (which stay around continuously even after the service's main process exited) are usually not suitable for activation via repetitive timers, as they will only be activated once, and then stay around forever.

So, remove RemainAfterExit=true and it will work.

  • BTW: You should be able to say OnCalendar=minutely, which is a bit clearer. Also you might want to mention AccuracySec (though the default one minute should be fine here).
    – derobert
    Oct 15, 2019 at 19:19

You must log in to answer this question.

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