For a project I want to use wget in a cron to download a data file. In the wget statement, a start- and enddate have to be defined in the following format:
wget --post-data="stns=235&vars=TEMP&start=YYYYMMDDHH&end=YYYYMMDDHH"
Since I want it to be done by a cron job, I would like the start- and enddate to be set automatically. More specific, I would like the startdate to be set to '1 hour ago' and the enddate to 'now'.
There has been a similar question in the post Using date -1day with wget. Here the suggested solution was to put the variables between single quotes, but this did not work. E.g.:
"[...]start='`date -d yesterday +%Y%m%d%H'&end=`date +%Y%m%d%H`"
I simply got the error "Error 400: Bad request" when trying to execute the wget-statement in the terminal.
Thank you.