service tomcat start/stop 和 ./catalina.sh run/stop 有什么区别

Whats the difference between service tomcat start/stop and ./catalina.sh run/stop

服务 tomcat start/stop 和 ./catalina.sh run/stop 在 Tomcat 或 TomEE 中有什么区别?

他们做的事情完全一样吗?

catalina.sh run 在前台启动 tomcat,在您启动它的控制台上显示日志。按 Ctrl-C 将终止 tomcat.

startup.sh 将在后台启动 tomcat。您必须 tail -f logs/catalina.out 才能查看日志。

除了 foreground/background 区别之外,两者都会做同样的事情。

其实startup.sh很小。如果您检查该文件,您会发现它依次调用 catalina.sh start。在 catalina.sh 中,您可以只搜索出现的 运行start 以查看它们的区别'已处理。

service tomcat start 通常在 Linux(或 *nix)的后台通过另一个(非 tomcat)OS-脚本启动守护进程,例如在 /etc/init.d。它通常还负责 运行ning tomcat 作为特定用户 (通常称为 "tomcat" 或类似名称)。如果您正在使用 Linux-发行版的 tomcat,您应该 从这个脚本开始。否则,您将面临临时文件或日志文件无法被覆盖的风险,因为它们属于您之前用来启动 tomcat 的不同用户。