I am writing a script which fetches some important data (via cronjob) from a url and sends an email if it failed, however, it doesn't seem to be recognising whether it failed or not (checking wget's return value [if]):
wget_output=$(wget --tries=1 --timeout=300 -r -N -nd -np --reject=html https://myurl/ -P ../data)
if [ $? -ne 0 ]
then
echo "send email here" >> ./test.txt
else
echo "send email here" >> ./test2.txt
fi
It just tries 1 time (as told) and then gives up, but doesn't recognise that it has either succeeded or not. I'm presuming I'm not handling the exit code correctly or something. Any idea? Thanks