We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


wget loop

bt707 asked
Medium Priority
Last Modified: 2013-12-26
Have a small scipt a friend made for running wget to pull down a file.

can someone explain what the varible here is actually doing, seems to just be keeping the loop going, what's the difference here in using this loop with wget and
just using a straight command to start wget such as

/usr/bin/wget -r -c -N -l 1 http://server.com/tmp/file1.gz

while [ $X = 1 ]
/usr/bin/wget -r -c -N -l 1 http://server.com/tmp/file1.gz


Watch Question

yes, the while is an infinite loop
Most Valuable Expert 2014
Top Expert 2015

Did you want to set $X depending on the result of the wget?


just wanted to verify that the while loop here was set just to be a infinite loop as ahoffmann said.

used this once to pull a big file to a remote server that has very bad bandwith and connections, worked out good. Just looking for a good way to run wget in a case like this where
connections are dropped and restarted sometimes, also where the command can be started then the session closed and reopened at a later time to check on the job.


not sure if your wget returns an error status for aborted downloads, if so replace the while with:
while [ $? -ne 0 ]

if your wget does not report an aborted download, use curl instead

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


thanks ahoffmann, I'll try this out, the wget works really good, I couldn't even kill it witout a kill, did try out a few test and even when killing it
then restarting it picks up right where it left off, very nice, will look into the curl also, never heard of it.

Thanks again.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.