gpt4 book ai didi

java - 我如何跟踪tomcat服务器?

转载 作者:行者123 更新时间:2023-11-28 23:14:15 25 4
gpt4 key购买 nike

要进行 strace,我需要一个 pid,但我无法通过运行获得任何 pid

pidof tomcat or pgrep tomcat

如果我们通过 systemctl 检查它的状态,我们会看到主 PID,但它的名字是 java。我们是否需要 strace java 才能 strace 那个应用程序?我不这么认为。结果

systemctl status tomcat

tomcat.service - Apache Tomcat Web Application Container Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2018-09-29 16:10:45 PKT; 1h 1min ago Process: 9618 ExecStop=/opt/tomcat/bin/shutdown.sh (code=exited, status=0/SUCCESS) Process: 14493 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS) Main PID: 14531 (java)
Tasks: 50 (limit: 4915) CGroup: /system.slice/tomcat.service
└─14531 /usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djav

最佳答案

Tomcat is written in Java so it will be a java process.

当以 root 或任何具有适当 sudo 权限的用户运行时,以下命令将跟踪 tomcat 服务。

strace -p `ps aux|grep -v grep|grep tomcat|awk '{print $2}'|head -n1`

enter image description here

enter image description here

此测试已作为 ROOT 在个人测试虚拟机上执行,建议不要在生产环境中使用它。

希望这能在一定程度上有所帮助。

关于java - 我如何跟踪tomcat服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52568316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com