- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Set Wget Connection Timeout in Linux?
Abstract
When working in a Linux environment, you have the freedom to decide how you want to download your files from a transparent URL. The majority of users are accustomed to Linux's interactive method of downloading such files. This interactive method involves using a web browser, where a user clicks on a download button that is available and waits until the file download has begun and is successfully finished.
An alternate method for obtaining network-based files through a non-interactive or command-line environment is the free GNU software Wget. The Wget utility's non-interactive property suggests that your file downloads can proceed or continue in the background even if the system user is not currently signed in to the Linux OS.
The Wget application supports retrieving files through FTP, HTTP, and HTTPS protocols. Moreover, it supports HTTP proxy-based file downloads. The setting of Wget timeout in a Linux operating system environment will be covered in this article to help while downloading files.
Note − Linux commands are case-sensitive.
Install Wget in Linux
On the majority of Linux distributions nowadays, the wget package is pre-installed.
Open your terminal, type wget, and hit Enter to see if the Wget package is installed on your machine. The computer will print wget: missing URL if wget is installed. Otherwise, wget command not found will be shown.
If wget isn't already set up, your package management makes it simple to do so.
Installing Wget on Ubuntu and Debian
$ sudo apt install wget
Installing Wget on CentOS and Fedora
$ sudo yum install wget
Wget Usage in Linux
The Wget GNU utility can be used using the following standard syntax −
$ wget [option]… [URL]...
There are various timeout options, including --dns-timeout, --connect-timeout, --read-timeout, and --timeout, so we must be explicit about the one we want.
Wget –dns-timeout Option
The maximum amount of time for a DNS lookup is specified by the -dns-timeout option.
$ wget --dns-timeout=5 https://github.com/the-vishal/Tutorials-Downloader/blob/master/README.md
The --dns-timeout=5 option suggests that DNS lookups taking longer than 5 seconds are failures.
Wget –connect-timeout Option
With TCP connections, you can use the wget —connect-timeout option.
$ wget --connect-timeout=3 https://github.com/the-vishal/Tutorials-Downloader/blob/master/README.md
The preceding wget command option (—connect-timeout=3) denotes that a TCP connection will be terminated if it takes longer than 3 seconds to establish.
Wget –read-timeout Option
When a user resumes reading/downloading data/files from a server but there is a transmission gap that causes Wget to wait on the server, the wget —read-timeout option can be helpful.
$ wget--read-timeout=3 https://github.com/the-vishal/Tutorials-Downloader/blob/master/README.md
You can provide your own wait time with —read-timeout in place of dealing with this unknowable wait time, and if it is surpassed, the file download will be stopped and restarted.
Wget –timeout Option
The value of the wget -timeout option, which is also known as the network timeout, is automatically inherited by all other Wget timeout settings. For example, the values for —dns-timeout, —connect-timeout, and —read-timeout will also assume the value of x if its value is x.
$ wget --timeout=6 https://github.com/the-vishal/Tutorials-Downloader/blob/master/README.md
In network setups with shaky connections or servers, the timeout parameters of the Wget GNU tool are useful for starting and finishing file downloads.
Conclusion
In network setups with shaky connections or servers, the timeout parameters of the Wget GNU tool are useful for starting and finishing file downloads.
In this tutorial, We've spoken about the wget command's timeout settings. For most downloads, we can simply use the default timeout settings.
Understanding these timeout settings, however, may help us adjust the timeouts so that the downloads are properly completed when we are in a specific network environment, such as one with erratic connections or servers.