I'm running the below command, and monitoring the output file on the other system:
ssh $ip_address 'for n in 1 2 3 4 5; do sleep 10; echo $n >>/tmp/count; done'
If I kill the ssh command using
^C or by just killing the terminal I'm logged in on, I'd expect the remote command to terminate, too. This doesn't happen, though:
/tmp/count gets all the numbers 1–5 regardless, and
ps -ejH shows the shell and its
sleep child continues running.
Is this expected behaviour, and is it documented anywhere? Can I disable it? From reading around, I'd expected to have to explicitly enable this sort of behaviour with nohup, not for it to be the default.
I've taken a look through the man pages for ssh and sshd, but not spotted anything obvious, and Google points me at instructions for turning this behaviour on, not for turning it off.
I'm running Red Hat Enterprise Linux 6.2, with a root login and bash shell on both systems.