質問

Can someone tell me what is wrong with wget statement I am running from cron?

wget -N --header="If-Modified-Since: `date -r testing.zip -P /home/test/public_html/resources/ --utc --rfc-2822 2>/dev/null || date --utc --rfc-2822 --date='1 week ago'`" http://www.test.com/files/zz666/testing.zip

The file gets retrieved OK, but writes to the /home directory and does not write to the /home/test/public_html/resources/ . The file will already exist in the target directory, so not sure if it is an overwrite issue? I have tried with a / on the end and without.

The date on the file that exist is always a week behind the file being downloaded.

Any help and advice appreciated.

役に立ちましたか?

解決

I think you have the -P parameter inside the header calculation:

wget -N -P /home/test/public_html/resources/ --header="If-Modified-Since: `date -r /home/test/public_html/resources/testing.zip  --utc --rfc-2822 2>/dev/null || date --utc --rfc-2822 --date='1 week ago'`" http://www.test.com/files/zz666/testing.zip

There is no -P option in date command ...

他のヒント

The reason for using wget is to pick up the latest scientiamobile.com WURFL.zip file. After contacting their support they confirmed their original wget documentation was wrong and they have corrected it. Having changed mine accordingly I can confirm it works perfectly now. The wget instruction is as follows:

WURFL_DIR=/home/test/public_html/resources; wget -N -P "$WURFL_DIR" --header="If-Modified-Since: $(date -r $WURFL_DIR/wurfl.zip --utc --rfc-2822 2>/dev/null || date --utc --rfc-2822 --date='1 week ago')" http://www.scientiamobile.com/wurfl/xxxx/wurfl.zip

Hope this helps someone else.

Regards, Chris.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top