I need some help. First of all, sorry about my english, that is not my native languaje.
I have a bash script in Solaris with the next lines:
And the sftp.sh has this:
The problem is that sometimes the sftp takes a long of time. I mean, 2 or 3 hours when it should be no more than 1 minute. I think there is a problem in the network, but i do not care about that in this moment.
So, i need to "cancel" that sftp and continue to the next line. It does not matter if the stfp is not finished.
I mean, can i add some kind of timeout to the sftp? I.e. 5 minutes. If it takes more than 5 minutes, continue to the next line.
Hello. That script runs every day in the morning, and the problem happens only a few times. Maybe 1 one time in the entire week.
I know we have to check where is the problem of the delay but in this moment i need to forget that and find a way to continue to the next line when the sftp is taking too long but i can�t find the solution.
Thanks a lot, it works splendidly. But i do not know if this is the solution.
I think that the "ConnectTimeout=10" property is only for connecting. I mean, if i want to connect to another server with sftp and i can�t connect after 10 seconds, it drops and it is fine.
But in my case, i can always connect to the remote server. The problem is when getting the files. Sometimes in the middle of the copy, it delays a lot (more than 1 hour). And in that case is where i want the script to cancel the sftp and to continue to the next line. Do you understand what I mean?
here's something I played around a bit many maaaany moons ago.
This might inspire some additional ideas.
The general idea is to "spawn" your potentionally long running process(es) (child1 and child2) to the background and check it after so many secs: if active kill it and continue (killing the "watcher" as well).
Indeed. This is a very good general-purpose kill-if-hung script, but in this case we "know" which file is being transferred, no? So we could, instead of guessing if the transfer is hung or just taking a long time check if the file size does change (=transfer still in progress) and base the timeout on that, no?
I think I understand and what I said earlier is to do with the server, what you will need to do is reconfigure the configuration files for either ssh or sshd these are normally in /etc/ssh .
I think that what you are looking for is the "Client Alive Settings", from memory there are three that you may have to look at;
The tcp_keep_alive setting.
The ClientAliveMax setting.
The ClientAliveInterval setting.
From memory you will have to set these and then restart the daemon to allow the changes to take effect. Although I'm still thinking that you should be having your network people do some investigations.