Failed to start tomcat.service: Unit tomcat.service not found
32,478
I'm using Ubuntu 16.04 while encountering this problem. I have solved it.
Firstly, add one line to the top of the script:
. /lib/lsb/init-functions
Then in shell, create symbolic links from /etc/rc* to my script:
sudo update-rc.d tomcat defaults 95
This will also make your script be running automatically after rebooting.
Related videos on Youtube
Author by
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I cannot seem to run a tomcat service from regular user and while I try this as root i get
root@ip-:/home/ubuntu# service tomcat Run as /etc/init.d/tomcat <start|stop|restart> root@ip-:/home/ubuntu# service tomcat start Failed to start tomcat.service: Unit tomcat.service not found. root@ip-:/home/ubuntu#
I did run it manually and it seemed to work
root@ip-:/home/ubuntu# /etc/init.d/tomcat start Using CATALINA_BASE: /usr/local/tomcat/current_tomcat Using CATALINA_HOME: /usr/local/tomcat/current_tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/current_tomcat/temp Using JRE_HOME: /usr/local/java/current_java Using CLASSPATH: /usr/local/tomcat/current_tomcat/bin/bootstrap.jar:/usr/local/tomcat/current_tomcat/bin/tomcat-juli.jar Tomcat started.
If i run it as a regular user I cannot seem to get permission. I have users under no pass word only ssh keys.
ubuntu@ip-:~$ service tomcat start ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to start 'tomcat.service'. Multiple identities can be used for authentication: 1. Ubuntu (ubuntu) 2. An,,, (an) Choose identity to authenticate as (1-2): 1 Password: polkit-agent-helper-1: pam_authenticate failed: Authentication failure ==== AUTHENTICATION FAILED === Failed to start tomcat.service: Access denied See system logs and 'systemctl status tomcat.service' for details. ubuntu@ip-:~$
And here is the script for service
ubuntu@ip-:~# cat /etc/init.d/tomcat #!/bin/bash export CATALINA_HOME=/usr/local/tomcat/current_tomcat` start() { sh $CATALINA_HOME/bin/startup.sh } stop() { sh $CATALINA_HOME/bin/shutdown.sh } case $1 in start|stop) $1;; restart) stop; start;; *) echo "Run as $0 <start|stop|restart>"; exit 1;; esac ubuntu@ip-:~# ll /etc/init.d/tomcat -rwxr-xr-x 1 root root 306 Feb 14 07:20 /etc/init.d/tomcat*
-
DarkCygnus about 6 yearsworked for me, although I didn't had to add that first line, and also dropped the 95 (but seems that leaving it is the same)