I have a systemd service I would like to keep running between set times (let's say midnight to 6 AM). The closest thing I have found so far is limiting it to a set amount of runtime:
[Unit]
Description=Do stuff
[Service]
ExecStart=/bin/do/stuff
#Stop service after hours
RuntimeMaxSec=21590s
#Once timeout is reached, kill all child processes (SIG15)
KillMode=control-group
#If service does not stop after 10s, consider it failed
TimeoutStopSec=10s
[Install]
WantedBy=multi-user.target
This service should be started at midnight by a timer, but it would be best if I could specify an exact time to stop the service in case it is manually started later.
Is there a method to this this with systemd? I prefer to avoid other tools to keep it simple.
Thanks!