Forwarding SIGTERM over ssh

2019-04-20 23:09发布

I want ssh to forward the SIGTERM signal to the remote command.

ssh root@localhost /root/print-signal.py

Get PID of ssh:

ps aux| grep print-signal

Kill the matching ssh process:

kill pid-of-ssh

Unfortunately only the ssh process itself gets the signal, not the remote command (print-signal.py). The remote command does not terminate :-(

How can I make ssh "forward" the SIGTERM signal to the remote command?

标签: ssh signals
2条回答
成全新的幸福
2楼-- · 2019-04-20 23:45

Send via SSH this (tested on sleep process):

$(proc=$(pidof sleep) && kill $proc)
查看更多
Lonely孤独者°
3楼-- · 2019-04-21 00:00

I think you can do the following :

ssh root@localhost /root/print-signal.py

**Get PID of python file running **

ps aux| grep print-signal

Kill the matching ssh process:

ssh root@localhost "kill <pid>"

Here you are sending command to remote host .

Hope this solves your problem .

查看更多
登录 后发表回答