【发布时间】:2021-12-02 05:42:13
【问题描述】:
我有一个名为productivity的进程正在运行
[root@productivity ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1009514/sshd
tcp6 0 0 :::8443 :::* LISTEN 2803472/productivit
tcp6 0 0 :::443 :::* LISTEN 1017657/httpd
tcp6 0 0 :::80 :::* LISTEN 1017657/httpd
tcp6 0 0 :::22 :::* LISTEN 1009514/sshd
udp 0 0 127.0.0.1:323 0.0.0.0:* 1009281/chronyd
udp6 0 0 ::1:323 :::* 1009281/chronyd
我会定期重启服务以更新我们的加密证书
[root@productivity ~]# cat restart-productivity.sh
#!/bin/sh
pkill "productivity"
bash -c "exec -a productivity java -jar productivity.jar -Dkeystore.location=./ssl/productivity.to.keystore . & disown &"
这几个月来就像一个魅力。现在,即使我手动运行pkill productivity,该服务也不会被终止。我只能通过调用kill PID 来终止服务。这确实有效,但对自动化毫无用处。
我在 CentOS 8 上运行,但我不知道它为什么停止工作。有谁能帮帮我吗?
更新
[root@productivity ecommerce]# ps aux | grep productivity
root 2803472 1.3 10.3 2648228 204168 pts/1 Sl 20:24 0:21 productivity -jar productivity.jar -Dkeystore.location=./ssl/productivity.to.keystore .
root 2803848 0.0 0.0 11800 1152 pts/1 S+ 20:49 0:00 grep --color=auto productivity
【问题讨论】:
-
如果你在 CentOS 8 上,你有 systemd。将其用于过程监督,不要尝试自己动手。一旦你用
ExecStart=/usr/bin/java -jar productivity.jar -Dkeystore.location=./ssl/productivity.to.keystore .定义了productivity.service,你就可以免费获得systemctl restart productivity,更不用说所有其他命令(systemctl status productivity,或journalctl -u productivity来读取它的日志等)。 -
请将
ps aux | grep productivity的输出添加到您的问题中。没有评论。 -
用
ps aux | grep productivity结果更新了我的问题 -
我投票结束这个问题,因为关于操作系统、它们的实用程序、网络和硬件的问题在这里是题外话。 What topics can I ask about here?。请删除此内容并转至Unix & Linux Stack Exchange