Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there any way I could trigger a bash script when ssh times out?

I have an alias to set the tmux title when starting ssh. The alias also includes a title change after the ssh session, which works if I do a clean exit, but if the session times out, the rest of the alias doesn't run.

share|improve this question
add comment

1 Answer 1

Wrap ssh with a shell script instead of an alias:

 #!/bin/sh
 echo "Setting up tmux and stuff..."
 # set up tmux and stuff

 ssh "$@"

 echo "Cleaning up..."
 # clean up
share|improve this answer
    
The only thing, it's not great with nested ssh connections. Otherwise it works perfect. –  rush Sep 6 '13 at 13:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.