[systemd-devel] Only start a tomcat server when you are sure that time-sync.target is online

Reindl Harald h.reindl at thelounge.net
Thu Mar 25 14:03:39 UTC 2021



Am 25.03.21 um 14:41 schrieb Jan Hugo Prins:
> Our current configuration looks roughly like this:
> 
> [Unit]
> Description=Apache Tomcat Web Application Container
> After=syslog.target time-sync.target
> Requires=time-sync.target
> 
> [Service]
> Type=simple
> ExecStart=Startscripts
> ExecStop=Stopscript
> SuccessExitStatus=143
> User=tomcatuser
> Group=tomcatuser
> Restart=on-failure
> 
> [Install]
> WantedBy=multi-user.target
> 
> The problem line is the Requires line in there I think.

yes

> Does systemd give me a different way to check if the time is in sync?
> Is there a way to create this dependency without implying a restart when
> ntpd restarts?
https://unix.stackexchange.com/questions/388586/systemd-requires-vs-wants

just replace "Requires" with "Wants", it does exactly the same but your 
Tomcat would also get started if "time-sync.target" is missing *but* it 
would not be stopped just because ntpd is stopped

there are really very few cases when Requires is really what someone wants


More information about the systemd-devel mailing list