如何在Ubuntu中停止tomcat7?


15

我已经使用命令apt-get安装了Apache tomcat7。现在,每当我启动系统时,tomcat就会运行。我想停止tomcat,以便可以在eclipse中启动它。

我尝试使用shutdown.sh命令停止它,但出现以下错误:

admin@admin-eMachines-E727:/usr/share/tomcat7/bin$ sudo /usr/share/tomcat7/bin/shutdown.sh
Using CATALINA_BASE:   /usr/share/tomcat7

Using CATALINA_HOME:   /usr/share/tomcat7

Using CATALINA_TMPDIR: /usr/share/tomcat7/temp

Using JRE_HOME:        /usr

Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar

Jun 02, 2014 9:37:59 AM org.apache.catalina.startup.ClassLoaderFactory validateFile

WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]

Jun 02, 2014 9:37:59 AM org.apache.catalina.startup.ClassLoaderFactory validateFile

WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]

Jun 02, 2014 9:38:00 AM org.apache.catalina.startup.ClassLoaderFactory validateFile

WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]

Jun 02, 2014 9:38:00 AM org.apache.catalina.startup.ClassLoaderFactory validateFile

WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]

Jun 02, 2014 9:38:00 AM org.apache.catalina.startup.ClassLoaderFactory validateFile

WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]

Jun 02, 2014 9:38:00 AM org.apache.catalina.startup.ClassLoaderFactory validateFile

WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]

Jun 02, 2014 9:38:00 AM org.apache.catalina.startup.Catalina stopServer

SEVERE: Catalina.stop: 

java.io.FileNotFoundException: /usr/share/tomcat7/conf/server.xml (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:468)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:371)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:458)

请为我建议这个问题的解决方案。提前致谢。

Answers:


20

通常,Ubuntu中的任何服务都可以由

sudo service <service_name> <argument>

这里的service_name代表服务的名称,在您的情况下为tomcat7

参数代表类型,如动作startstoprestartstatus,你的情况是stop

所以最后您可以使用以下命令停止tomcat7。

sudo service tomcat7 stop

3
停止是一次性交易。他需要使用sudo update-rc.d tomcat7 disable它来阻止它在启动时随PC重新启动
Virusboy

1

我已经尝试了几乎所有为此找到的一切,但最终得出结论,这是最佳,简单和精确的解决方案:

sudo systemctl start tomcat

这是用于启动服务的

如果要检查状态,则

sudo systemctl status tomcat

并停止:

sudo systemctl stop tomcat

接受的答案如何改善?
查尔斯·格林

这只是另一个直接的终端命令,它还阻止了Tomcat重新启动后重新启动。
INagwani
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.