1

When using wget's -O flag, the program writes a bunch of zero byte files when it fails.

My question is, will the size always be zero? Or, can a non-zero byte file also be created when a download fails?

I am writing a script and my assumption is that only zero byte files indicate failure.

1 Answer 1

3

No, it is not guaranteed that the file would be empty if there is an error. If there is an error midway the download, whatever was downloaded before that moment will be in the output file.

Only in the case of receiving an error in HTTP protocol will the file be empty.

I did even a test by downloading a file and stopping the HTTP server in the middle.

dd [ <=> ] 1.01K --.-KB/s in 0s
2015-12-14 12:53:40 (9.69 MB/s) - Read error at byte 1038 (Success).Retrying.

So wget will retry, but if it doesn't succeed, a partial file will be written.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .