On my server I have the script that runs (using a cronjob) every midnight and downloads a zip which contains a csv file from an url. The csv file is updated daily. Following is my (simple) script:

#!/usr/bin/env bash
rm -f /home/croaz/public_html/tmp/flatfile_rom_air.*

wget --no-cache --user user_name --password password     http://www.url.com/DownloadArea/ROM/flatfile_rom_air.zip -P /home/croaz/public_html/tmp/ && unzip flatfile_rom_air.zip -d /home/croaz/public_html/tmp/ 

However, I get a very weird behavior. While the zip package contains the updated csv file, the unzipped (csv) file is the same as it was when I first run the script (a couple a months ago). It behaves as the unzip would use some cached copy of the csv file. If I download the zip archive from my server on my local PC, and unzip it there, everything works as it should be (I get the updated file). What am I missing?


Have you actually looked into the directory to see what's in there?

By default, wget won't overwrite existing files, but instead append a number to the name (index.html.1 etc), so your script is just using the old file over and over again. Use the -O option to specificy the output name and prevent this.

  • I'm deleting the existing file before everything else so that the folder is empty. I also tried deleting manually everything from that folder so that to be sure that the folder is empty. Still no change.I will try to rename the file as you suggested – sica07 Aug 1 '16 at 8:52
  • it worked by changing the output name (I have no idea why, but it works this way). Thks – sica07 Aug 2 '16 at 8:53

Have you checked that the user that runs the cronjob has write permissions to the directory / files so that the rm and wget can actually remove / write files?

  • yes. No problem with that. – sica07 Aug 2 '16 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.