How to Set Custom Wait Time After wget Download on Ubuntu
This guide explains how to configure a custom delay after a file download completes using the wget command in Ubuntu. You will learn that while wget lacks a native flag to pause after the final retrieval, you can achieve this by chaining commands or using options for batch downloads. The instructions below detail the specific syntax required to manage timing effectively.
Wait After Single File Download
The wget utility does not have a built-in option to sleep after the
final download finishes. To specify a custom wait time after a
successful download, you must chain the wget command with the sleep
command using the shell logical AND operator (&&).
This ensures the delay only occurs if the download exits
successfully.
wget https://example.com/file.zip && sleep 10In this example, the system downloads the file and then pauses execution for 10 seconds before returning control to the terminal or proceeding to the next command in a script.
Wait Between Multiple Downloads
If you are downloading multiple files from a list and want to insert
a delay between each retrieval, use the --wait option. This
specifies the number of seconds to wait between successful
downloads.
wget --wait=5 -i download-list.txtThis command reads URLs from download-list.txt and waits
5 seconds after each file completes before starting the next one.
Using Random Wait Times
To be polite to servers and avoid triggering rate limits, you can
combine --wait with --random-wait. This
randomizes the wait time between 0.5 and 1.5 times the value specified
in the --wait option.
wget --wait=5 --random-wait -i download-list.txtThis results in a random delay between 2.5 and 7.5 seconds between each download.