Background
I've got a QNAP NAS box running on my network and I want to run a cron job periodically to call a web page that will then update a Dynamic DNS service with my router's public IP address. I want to be able to take the outout of this PHP file and append to a log file.
For testing I've created a test.php file that just echos back some text.
Here are the relevant bits and pieces:
https://www.example.com/test.php
<?php
echo "Hello world!\n";
?>
updateddns.sh
# updateddns.sh
########## Edit the following lines ##########
Logfile="/share/Public/ddns.log"
URL="https://www.example.com/test.php"
Token="lPpbyP22M1ePvthsJ0uO"
##############################################
date >> $Logfile
wget -4q -O - --post-data="auth=$Token" $URL >> $Logfile
echo "Complete" >> $Logfile
crontab (extract)
*/5 * * * * /bin/sh /share/Public/updateddns.sh
DVNK5C~Q (extract)
Fri Jan 19 10:00:00 GMT 2018
Complete
Fri Jan 19 10:05:00 GMT 2018
Complete
Fri Jan 19 10:10:00 GMT 2018
Complete
Fri Jan 19 10:15:00 GMT 2018
Complete
Fri Jan 19 10:20:00 GMT 2018
Complete
Fri Jan 19 10:25:00 GMT 2018
Complete
Fri Jan 19 10:30:00 GMT 2018
Complete
As you can see the cron job is running logs the date and the "Complete" text but nothing from the wget command. The other thing to note here is that rather than logging to ddns.log the output is logged to a file called DVNK5C~Q (when viewed in Windows) which looks like it's called ddns.log?? when viewed in a shell command window.
If I run the wget command directly from the shell prompt it works and I get "Hello world!" written out to the correct ddns.log file.
Anyone point me in the right direction here?
Thanks, Stuart.