There is a very similar question to this, but there is an extra detail I have in my situation.
Basically I am using a ControlMaster to speed up SSH connections. So I am using:
CurrentUser=$(whoami)
session=$(ps -el | grep $(id -u) |sed -e 's/sshd//g'| grep ssh)
if [ "$session" = "" ]
then
ssh -TMNf synchro@129.130.155.30 &
fi
After this code I have another command. The purpose of the ssh command is solely to run in the background in order to keep an open socket for faster connections (if no calls occur for a short time then it times out and closes due to inactivity.)
The problem is this script doesn't close and return to the caller. It becomes a < defunct > process, and doesn't return until I manually kill the created ssh session. How can I let the script return to the caller and have the created ssh run in the background?
Edit: I want the created ssh session to persist after the script ends to keep a socket open for faster connections with an rsync command after this. With an open socket I go from 3-4 second transfer times to milliseconds
-
you want to work with the nohup command?
Josh : nohup is interesting +1, and I might actually need it, but the problem isn't with the ssh session getting killed after the script terminates, it's with returning to the calling script from the script that creates the ssh session. (I tried it and no dice :()Josh : I got it using your link - `nohup ssh -TMNf synchro@129.130.155.30 >/dev/null 2>&1From nikHow about giving autossh a try:
http://www.harding.motd.ca/autossh/
It manages the SSH connection for you and returns to the caller once you kick it off.
Josh : I'd like to get my custom solution working if possible, if no other feasible answers exist I will look into implementing\learning `autossh`.From vmfarms
0 comments:
Post a Comment