Solved

wget overwriting files

Posted on 2011-02-26
10
649 Views
Last Modified: 2012-05-11
I am issuing a wget statement:

wget -c -np -r -N -l inf -w 5 --limit-rate=200K http://www.mysite.com/files

The problem is that it's wasting time downloading files that it already has.  If the files match, I don't want to take the time to download it.
0
Comment
Question by:hrolsons
  • 6
  • 3
10 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 34989146
Hi,

that's a case for timestamping.

Use "-S" for the first download ("preserve timestamps") and "-N" ("newer") for subsequent downloads.

With "-N" ...

... Wget will ask the server for the last-modified date. If the local file has the same timestamp as the server, or a newer one, the remote file will not be re-fetched. However, if the remote file is more recent, Wget will proceed to fetch it.

The above quote is from here:
http://www.gnu.org/software/wget/manual/wget.html#Time_002dStamping-Usage

Good luck!

wmp
0
 

Author Comment

by:hrolsons
ID: 34989201
So, I would change it to :

wget -c -np -r -S -l inf -w 5 --limit-rate=200K http://www.mysite.com/files

for the first, and then:

wget -c -np -r -N -l inf -w 5 --limit-rate=200K http://www.mysite.com/files

Bummer that I have to start this huge download back over again.
0
 
LVL 12

Expert Comment

by:mccracky
ID: 34997534
I don't think so.  From the wget man page:

-N
--timestamping
           Turn on time-stamping.
-S
--server-response
           Print the headers sent by HTTP servers and responses sent by FTP
           servers.

The "-N" already does the timestamping.

What format is the disk filesystem that you are downloading to?  Can it preserve the permissions and timestamps of the original system?  (also, would rsync be an option?)
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:hrolsons
ID: 34998674
I am downloading to  Windows XP, running GnuWin.

Yes, rsync would be an option.  What would I gain?
0
 
LVL 12

Expert Comment

by:mccracky
ID: 34998991
Is it NTFS or FAT that you are downloading to?
0
 

Author Comment

by:hrolsons
ID: 34999080
NTFS
0
 
LVL 12

Expert Comment

by:mccracky
ID: 34999291
Here is a page talking about the differences between Windows and Linux with respect to timestamps:
http://samba.anu.edu.au/rsync/daylight-savings.html

That might be the problem.  Or that the webserver is not giving out the times (see http://permalink.gmane.org/gmane.comp.web.wget.general/9977)

With rsync you usually use a shell rather than the webserver to download the files so the timestamps might work better.  

If that fails, then with rsync, there is the option "-c" to only compare file checksums rather than time and sizes when doing a transfer.  
0
 

Author Comment

by:hrolsons
ID: 34999375
It seems to be working right now, which makes no sense.  Also, I had to add a trailing backslash to my original command to get it to work right.
0
 

Accepted Solution

by:
hrolsons earned 0 total points
ID: 35186498
It was all about that trailing backslash:

This is incorrect:
wget -c -np -r -N -l inf -w 5 --limit-rate=200K http://www.mysite.com/files

This works:
wget -c -np -r -N -l inf -w 5 --limit-rate=200K http://www.mysite.com/files/
0
 

Author Closing Comment

by:hrolsons
ID: 35221365
It worked
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question