SOLVED Cron job to test file time and send email?

ATom1

Registered
May 21, 2018
3
0
1
Utah
cPanel Access Level
Website Owner
My home network uploads a file with the date and time, which happens every five minutes. I wish to create a cron job which checks this file and sends me an email if the file is not updating. This would be an indication that my home network has lost internet connectivity.

I have been using cPanel for years, and create my own content. Just haven't used cron jobs at all.

Thanks for any assistance.
 

ATom1

Registered
May 21, 2018
3
0
1
Utah
cPanel Access Level
Website Owner
I have created a cron job as follows:
Code:
/usr/bin/php -q /home2/myusrname/public_html/CheckHome.php >/dev/null
Here is the CheckHome.php file contents:
Code:
<?php
// the message
$msg = "Internet down";

$filename = 'clientFTP/marquee.txt';
$t = time();
$ft = (filemtime($filename));
$td = (($t - $ft)/60);
if ((file_exists($filename)) and $td > 5) {
   mail("[email protected]","Alert",$msg);
}
?>
I tested the php script independently, so I know it works. However, I am not getting a text when the file is not being updated. The file is normally updated once per minute.