![](/img/trans.png)
[英]How can I remove session related information from database when the session gets killed?
[英]process gets killed on server when closing SSH session
我使用 PuTTY 通過 SSH 連接到我的 Linux (centos 8) 服務器。 然后我通過命令在服務器上運行我的 java 程序
java -cp /.../ app
一切都很好,程序連續運行,但是當我在 PuTTY 中關閉 SSH session 時,我的 java 程序也會被殺死。 為什么會發生以及如何預防?!
這是預期的行為。 If you want to keep running your java jar file even though you close the SSH putty session, create a shell script and try to run the java application through running the shell script.
示例腳本如下所示,您可以根據需要進行修改:
Name the script : app.sh
示例腳本內容:
#!/bin/sh
cd /home/user/ #path where your jar file is kept
java -jar app.jar
Go 到腳本的位置:
Give proper execute permissions to the script app.sh :
chmod 755 app.sh
Run the script as : ./app.sh
nohup java -jar test.jar &
nohup 是一個忽略 HUP(掛斷)信號的 POSIX 命令。 按照慣例,HUP 信號是終端警告相關進程注銷的方式。
Output 通常會 go 到終端轉到名為 nohup.out 的文件,如果它尚未被重定向。
簡而言之,它代表不掛斷。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.