How do I kill a remote login session as well as processes started inside it?
Issue
- How do I
kill
a remote login session as well as processes started inside it? - If the user terminates the SSH session by hitting the X button, it leaves the
script
processes running. - How can I configure the
.profile
to clean up (kill) the processes if the user terminates the SSH session? - We have added below script inside
.profile
which is not working:
set -x
PATH=$PATH:$HOME/bin
export PATH
trap "kill -15 0; exit" EXIT INT HUP
scriptname
kill -15 0
Environment
- Red Hat Enterprise Linux 6.X
- util-linux
- ssh
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.