I currently have a setup where I have an emergency server which on a scheduled basis grabs files from my main webserver using wget. If all goes well I want wget to clobber the old cached file. However, if the request returns 404 or something else goes wrong where data cannot be retrieved (e.g. my main server goes down), I don't want the cached data to get clobbered. I've tried using -N which correctly clobbers the data if a new version is available. However, if there is a 404 it clobbers that data with 0 byte files.
Tell me more
×
Unix & Linux Stack Exchange is a question and answer site for
users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
|
|
If you can modify your web server's configuration or allowed to have .htaccess, you can setup custom error pages. For example, assuming apache as webserver, make an error page
Together with the alias directive, you can use the same error pages for multiple vhosts if you have more than one. This alone should help not clobbering, but you can also add |
|||
|
|
|
Make a copy of the file before calling wget. (There doesn't seem to be a way to tell wget to unlink and recreate rather than clobber the file.)
|
|||
|
|