I have script in my /etc/profile, this goes and works well when SSh connection is established to the router and then exited from terminal by typing exit, but it fails to run ./finalise script when connection suddenly drops.
if [ -n "$SSH_CONNECTION" ]; then
./startup.sh
trap './finalise.sh' EXIT
fi
Is there anything we can do to run finalise script every time when there is no SSH connections, i.e. last one was dropped/disconnected?