I am trying to run a script every hour that check if a file has been changed, and if it has then it sends an email. So I found in another post (PHP - Email notification whenever a remote file changes) this:
$url='http://media1.clubpenguin.com/play/en/web_service/game_configs/paper_items.json';
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$execute = curl_exec($ch);
$fp=fopen('old.json','w+');
$oldjson=fread($fp,filesize('old.json'));
if($execute!=$oldjson){
mail('your@mail.com','Yoohoo', 'File changed');
fputs($fp,$execute);
}
fclose($fp);
and placed both files (the blank old.json and scriptTestForCron.php) in my cron.hourly folder. I changed the url given in the example to the filepath to the file I want to see if is changed, as well as the mailing information. The problem is that it does not notify me that it failed, and does not send an email so I do not know if it actually ran or not. Is there any way I could check? Also what reason could it not currently be working?
I have attempted to change my crontab file to run this and send logs to a specific file but have not been able to receive anything yet.
# run-parts
15 * * * * root run-parts /etc/cron.hourly
# php
1 * * * * php /etc/cron.hourly/scriptTestForCron.php >> /var/log/testLog
Shouldn't one of those two lines be running the script file?