LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-28-2011, 05:54 PM   #1
YaMaHaBoB
LQ Newbie
 
Registered: Aug 2006
Posts: 24

Rep: Reputation: 0
simple wget questions


If I have an address, say example.com, and I want to run n number of wgets on it. How can I do this? I'm curious for the reason of checking how wgets caches DNS.

‘--no-dns-cache’
Turn off caching of DNS lookups. Normally, Wget remembers the IP addresses it looked up from DNS so it doesn't have to repeatedly contact the DNS server for the same (typically small) set of hosts it retrieves from. This cache exists in memory only; a new Wget run will contact DNS again.

The last part confuses me. " a new Wget run will contact DNS again." This means if I run a for-loop to call wget on an address, it will just make a new call to DNS every time. How do I avoid this?
 
Old 06-28-2011, 06:21 PM   #2
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Passing several urls to wget in the same command line, eg: wget url1 url2 url3
 
Old 06-28-2011, 06:36 PM   #3
YaMaHaBoB
LQ Newbie
 
Registered: Aug 2006
Posts: 24

Original Poster
Rep: Reputation: 0
Even if the URLs are the same?
 
Old 06-28-2011, 06:51 PM   #4
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
In that case wget will save the pages as page.html, page.html.1, page.html.2 and so on. But it won't contact DNS again because it already resolved for the first page.
 
Old 06-28-2011, 07:10 PM   #5
YaMaHaBoB
LQ Newbie
 
Registered: Aug 2006
Posts: 24

Original Poster
Rep: Reputation: 0
So then it will be making a new DNS request per page which won't help me. I need to know how long it caches an entry.
 
Old 06-28-2011, 07:23 PM   #6
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by YaMaHaBoB View Post
So then it will be making a new DNS request per page which won't help me. I need to know how long it caches an entry.
It will make new DNS requests each time you invoke wget. If you run it once, with several urls, then it will use the DNS cache, which lasts for the duration of the execution of the program.

It will also use the DNS cache if page A links to B, and page C also links to B. When downloading page C, it won't make a DNS request for page B, which is already in the cache.

The option you mention, --no-dns-cache, will disable this behavior. Take a look at the manpage again:

Code:
       --no-dns-cache
           Turn off caching of DNS lookups.  Normally, Wget remembers the IP
           addresses it looked up from DNS so it doesn't have to repeatedly contact
           the DNS server for the same (typically small) set of hosts it retrieves
           from.  This cache exists in memory only; a new Wget run will contact DNS
           again.

           However, it has been reported that in some situations it is not desirable
           to cache host names, even for the duration of a short-running application
           like Wget.  With this option Wget issues a new DNS lookup (more precisely,
           a new call to "gethostbyname" or "getaddrinfo") each time it makes a new
           connection.  Please note that this option will not affect caching that
           might be performed by the resolving library or by an external caching
           layer, such as NSCD.

           If you don't understand exactly what this option does, you probably won't
           need it.
 
1 members found this post helpful.
Old 06-28-2011, 07:39 PM   #7
YaMaHaBoB
LQ Newbie
 
Registered: Aug 2006
Posts: 24

Original Poster
Rep: Reputation: 0
I see now! Well aside from inlining the entire is there another way? The truth of the matter is that I need to compare the file produced in between each call, but I also need to not make a new call to DNS each time...

Last edited by YaMaHaBoB; 06-28-2011 at 07:41 PM. Reason: typo
 
Old 06-28-2011, 07:56 PM   #8
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by YaMaHaBoB View Post
I see now! Well aside from inlining the entire is there another way? The truth of the matter is that I need to compare the file produced in between each call, but I also need to not make a new call to DNS each time...
Another way? Hmm... Can't think of one right now. Why is it you can't run it with several urls? Each downloaded file gets a different name, so comparing them afterwards seems possible. The issue with the DNS cache is that it lives for the duration of the wget run, each new invocation creates a new cache. It's not persistent.

It seems to me that you'll need to adjust your script to the behavior of the software. Or change the software. In any case, good luck!
 
1 members found this post helpful.
Old 06-28-2011, 08:02 PM   #9
YaMaHaBoB
LQ Newbie
 
Registered: Aug 2006
Posts: 24

Original Poster
Rep: Reputation: 0
Well, I'm testing a dynamic DNS setup and I'm wanting to see how my system acts when the cached DNS is invalid. I'm trying to redirect the old traffic to a different computer.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple questions that need simple answers Mr-Bisquit General 2 07-09-2010 02:46 PM
Simple question on wget Mithrilhall Linux - Software 3 01-22-2009 02:17 PM
Simple Questions...Hopfully Simple Answers. caps_phisto Linux - General 3 12-21-2004 12:40 PM
simple wget question hcclnoodles Linux - Software 2 09-29-2004 06:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration