Why the follow ssh command doesn't exit immediately. Instead, it will exit after 1m
ssh -vvv <usr>@<ip> 'sh -c "sleep 60 &"'
But I do tell shell to run sleep command in the background, I don't know why
It's because the file descriptors opened by the sh
process are indirectly connected to your ssh session's tty.
sleep
command does not take anything on stdin
not does it send anything back to stdout/stderr
. However, the FDs inherited from sh
are still open.
The way out is to close those FDs by ip/op/err redirection.
ssh -vvv <usr>@<ip> 'sh -c "sleep 60 &" &>/dev/null </dev/null'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.