[systemd-devel] How to stop service by timer

Mikhail Kasimov mikhail.kasimov at gmail.com
Mon Sep 12 19:03:37 UTC 2016


Hello!

How does your service work from 10:00 till 18:45 -- with any 
interruption during this time-range, or constantly? I'm asking, because 
I'm not sure if RuntimeMaxSec= directive 
(https://www.freedesktop.org/software/systemd/man/systemd.service) is 
acceptable here|.
|

So, you start your service by timer on 10:00 and due to 
RuntimeMaxSec=31500 in [Service] section of your service, service should 
stop on 18:45:00 it should be stopped with exit code 0. But if it 
happens on 18:45:01 -- will stop with exit with failure state. In that 
case, if FailureAction= directive 
(https://www.freedesktop.org/software/systemd/man/systemd.service) for 
your service is set, it will be executed.


12.09.2016 21:13, Федор Короткий пишет:
> Hi,
>
> We are trying to setup a service that runs every day from 10:00 to 18:45.
>
> Starting is not a problem, we just used timer. But our solution for
> stopping the service seems ugly. We have second service with
> Type=oneshot which runs "systemctl stop first.service" at 18.45(by
> using second timer).
>
> Is there a better way to achieve this?
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20160912/369f2929/attachment.html>


More information about the systemd-devel mailing list