通过 ssh 转发 SIGTERM [英] Forwarding SIGTERM over ssh
问题描述
我希望 ssh 将 SIGTERM 信号转发给远程命令.
I want ssh to forward the SIGTERM signal to the remote command.
ssh root@localhost /root/print-signal.py
获取 ssh 的 PID:
Get PID of ssh:
ps aux| grep print-signal
杀死匹配的 ssh 进程:
Kill the matching ssh process:
kill pid-of-ssh
不幸的是,只有 ssh 进程本身获得信号,而不是远程命令 (print-signal.py
).远程命令不会终止:-(
Unfortunately only the ssh process itself gets the signal, not the remote command (print-signal.py
). The remote command does not terminate :-(
如何让 ssh 将 SIGTERM 信号转发"到远程命令?
How can I make ssh "forward" the SIGTERM signal to the remote command?
推荐答案
我认为您可以执行以下操作:
I think you can do the following :
ssh root@localhost /root/print-signal.py
**获取正在运行的python文件的PID **
**Get PID of python file running **
ps 辅助|grep 打印信号
ps aux| grep print-signal
杀死匹配的 ssh 进程:
Kill the matching ssh process:
ssh root@localhost "kill <pid>"
这里是向远程主机发送命令.
Here you are sending command to remote host .
希望这能解决您的问题.
Hope this solves your problem .
这篇关于通过 ssh 转发 SIGTERM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!