2

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?

2 Answers 2

3

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.

3
  • 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, 2016 at 8:52
  • it worked by changing the output name (I have no idea why, but it works this way). Thks
    – sica07
    Aug 2, 2016 at 8:53
  • I have the same problem. What is that? Folder is empty. I copy the zip file to it and run unzip. But the result is previous one which was in there before but was damaged. Now I am not able to unzip the new version. Why should I rename the zip file?
    – Čamo
    Mar 4, 2021 at 19:28
0

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?

1
  • yes. No problem with that.
    – sica07
    Aug 2, 2016 at 8:54

You must log in to answer this question.

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