2

I needed to set up an Ubuntu server based Tomcat server and I followed this well written post. Everything works great. Ran into an odd behavior though; I needed to stop the Tomcat server, so I used the command:

sudo /opt/tomcat/bin/shutdown.sh

However, in about 10 seconds, Tomcat automatically restarted. How is that happening? Does the following command:

sudo systemctl enable tomcat

automatically start the Tomcat service, if its status is periodically checked and found to be stopped?

Web User
  • 123
  • 1
  • 5

1 Answers1

4

You should start, restart, stop tomcat with systemd commands. You have started tomcat servicesudo systemctl start tomcat, so if you want to stop it you need to go trough systemd:sudo systemctl stop tomcat. In the unit file, according to the link that you posted, are settings that are: RestartSec=10 which instructs systemd to restart tomcat.service after 10 sec in the case of failure or exit, and Restart=always instructs systemd to do it restart tomcat.service always no mater what is the reason of failure or exit, except if it was due systemd action. There is good explanation here. So you are trying to shutdown tomcat beside systemd, and systemd sees that as some irregularity in tomcat.service behavior and restarts it.

This command:

sudo systemctl enable tomcat

tells systemd to start the tomcat.service on the system startup, and nothing else.

dexter
  • 64
  • 1
  • 5