Solved

wget overwriting files

Posted on 2011-02-26
10
646 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
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.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now