Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PID file found but either no matching process was found or the current user does not have permission to stop the process

I'm facing a problem with Apache Tomcat 9.0.50, Ubuntu Server 18.04 LTS and Java JDK 8.

I am not able to start Tomcat9 as a service, because if I check its status after started, it shows the error: PID file found but either no matching process was found or the current user does not have permission to stop the process. Stop aborted.

I've created a dedicated group and user for Tomcat (group tomcat9, user tomcat9).

If I check the ps (process-show) Linux tool, for example with:

ps -faux | grep tomcat

Tomcat is not present, so the process is not active.

I'm running sudo systemctl start tomcat.service

with the "sadmin" account that belongs to sudoers and also belongs to tomcat9 group.

Jul 06 17:14:55 i-s-023 systemd[1]: Starting Tomcat9...
Jul 06 17:14:55 i-s-023 startup.sh[5257]: Existing PID file found during start.
Jul 06 17:14:55 i-s-023 startup.sh[5257]: Removing/clearing stale PID file.
Jul 06 17:14:55 i-s-023 startup.sh[5257]: Tomcat started.
Jul 06 17:14:55 i-s-023 shutdown.sh[5279]: PID file found but either no matching process was found or the current user does not have permission to stop the process. Stop aborted.
Jul 06 17:14:55 i-s-023 systemd[1]: tomcat.service: Control process exited, code=exited status=1
Jul 06 17:14:55 i-s-023 systemd[1]: tomcat.service: Failed with result 'exit-code'.
Jul 06 17:14:55 i-s-023 systemd[1]: Failed to start Tomcat9.

Here it is my /opt folder:

drwxr-xr-x  4 root    root        4096 Jul  6 14:44 .
drwxr-xr-x 24 root    root        4096 Jun 24 01:26 ..
drwxr-xr-x  9 tomcat9 tomcat9     4096 Jul  6 16:43 apache-tomcat-9.0.50
-rw-r--r--  1 root    root    11507318 Jun 28 10:52 apache-tomcat-9.0.50.tar.gz
drwxr-xr-x  7 root    root        4096 Jul  6 16:34 jdk1.8.0_221
lrwxrwxrwx  1 root    root          20 Jul  6 14:44 tomcat-latest -> apache-tomcat-9.0.50

Those are permissions inside /opt/tomcat-latest folder

drwxr-xr-x 9 tomcat9 tomcat9  4096 Jul  6 16:43 .
drwxr-xr-x 4 root    root     4096 Jul  6 14:44 ..
drwxrwx--- 2 root    tomcat9  4096 Jul  6 14:44 bin
-rw-r----- 1 root    tomcat9 18949 Jun 28 10:46 BUILDING.txt
drwxr-x--- 2 root    tomcat9  4096 Jun 28 10:46 conf
-rw-r----- 1 root    tomcat9  6210 Jun 28 10:46 CONTRIBUTING.md
drwxr-x--- 2 root    tomcat9  4096 Jul  6 14:44 lib
-rw-r----- 1 root    tomcat9 57092 Jun 28 10:46 LICENSE
drwxr-x--- 2 tomcat9 tomcat9  4096 Jul  6 14:46 logs
-rw-r----- 1 root    tomcat9  2333 Jun 28 10:46 NOTICE
-rw-r----- 1 root    tomcat9  3372 Jun 28 10:46 README.md
-rw-r----- 1 root    tomcat9  6898 Jun 28 10:46 RELEASE-NOTES
-rw-r----- 1 root    tomcat9 16507 Jun 28 10:46 RUNNING.txt
drwxr-x--- 2 tomcat9 tomcat9  4096 Jul  6 17:14 temp
drwxr-x--- 7 tomcat9 tomcat9  4096 Jun 28 10:46 webapps
drwxr-x--- 2 tomcat9 tomcat9  4096 Jun 28 10:46 work

The service is defined as shown below:

[Unit]
Description=Tomcat9
After=network.target

[Service]
Type=forking
User=tomcat9
Group=tomcat9
WorkingDirectory=/opt/tomcat-latest/bin
Environment=CATALINA_PID=/opt/tomcat-latest/temp/tomcat9.pid
Environment=JAVA_HOME=/opt/jdk1.8.0_221
Environment=CATALINA_HOME=/opt/tomcat-latest
Environment=CATALINA_BASE=/opt/tomcat-latest
Environment="CATALINA_OPTS=-Xms1280m -Xmx3840m"
Environment="JAVA_OPTS=-Dfile.encoding=UTF-8 -Dnet.sf.ehcache.skipUpdateCheck=true -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC  -Dorg.apache.tomcat.util.buf.UDec$

ExecStart=/opt/tomcat-latest/bin/startup.sh
ExecStop=/opt/tomcat-latest/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

Do you have any advice? Thanks in advance

like image 946
Roberto Milani Avatar asked Dec 09 '25 18:12

Roberto Milani


2 Answers

Ensure that the Environment points to existing path. In my case JAVA_HOME was set to non existent java.

like image 139
7guyo Avatar answered Dec 12 '25 08:12

7guyo


I had a same issue short time ago.My problem was systemd unit file was addressing wrong arch java.Changed JAVA_HOME and fixed.

like image 34
Ferhat Kacar Avatar answered Dec 12 '25 08:12

Ferhat Kacar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!