I am using the following command to set timeout of lftp command so that if the server is not available or is not accepting any new connection, the command ends after 10 sec.
lftp -e 'set ftp:passive-mode true; set net:timeout 10; cd /OUT; mput $filename; bye' -u mylftpuser,mypassword myhost.com
However, the timeout does not seem to work. When I run the above command on the command prompt, it retries connecting after 30 sec, 45 sect ..60 sec ...and never ends.
Am I doing something wrong here?
Thanks.
It's because of the very high default of net:max-retries 1000
which is:
the maximum number of sequential tries of an operation without success. 0 means unlimited. 1 means no retries.
Change it (in your ~/.lftp config file) to something like 5 and you're good to go.
I had the same problem with timeout not working when I used:
lftp -e "set net:timeout 5" -u user,pwd server
I have removed the -e "set..."
part and use only lftp -u user,pwd server
and the commands insert it into ~/.lftp/rc file:
cat ~/.lftp/rc
set net:timeout 5
set net:max-retries 2
set net:reconnect-interval-base 5
This works fine for me now.
In the documentation you can find more information about the location of the settings and the available options. Below you can see the file locations of the settings.
On startup, lftp executes ~/.lftprc
and ~/.lftp/rc
(or ~/.config/lftp/rc
if ~/.lftp
does not exist). You can place aliases and set commands there. Some people prefer to see full protocol debug, use debug
to turn the debug on.
There is also a system-wide startup file in /etc/lftp.conf
. It can be in different directory, see FILES section.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With