开发者

Preferred way to terminate `ssh -N` in background using bash?

I've started ssh -N <somehost> & in a bash script (to create a tunnel), and the connection persists after the script ends, and I see with ps that the ssh pro开发者_运维知识库cess has detached.

I am currently killing the background job with kill jobs -p, but is there a better way to do that?


Do you manually end your script?
if so:
     Try to catch the QUIT signal (or others) inside your script (use the trap builtin command I think). Then kill ssh.
else:
     Kill ssh at the end of your script.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜