-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathcronjobs.php
More file actions
27 lines (22 loc) · 1.01 KB
/
cronjobs.php
File metadata and controls
27 lines (22 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
/* SCRIPT FOR VERIFYING EXECUTION OF CRONJOBS ~ TEBEL.SG */
$result = ""; date_default_timezone_set('Asia/Singapore'); // use following per job to check if job log file is updated
if (date('Y-m-d') !== date('Y-m-d',filemtime("/full_path_on_your_server/weather.log"))) $result = $result . "Weather_API, ";
if ($result == "")
echo "All jobs ran today" . "\n"; // do not take any further action
else
{
$result = substr($result, 0, strlen($result) - 2);
echo $result . " didn't run today. ";
$_GET['OUTPUT'] = "TEXT";
$_GET['SENDTO'] = "your_email@gmail.com"; $_GET['SENDFROM'] = "Your Name <your_email@gmail.com>";
$_GET['SUBJECT'] = "CronJobs Alert"; $_GET['MESSAGE'] = $result . " didn't run today.";
sendmail_service();
}
/* SENDMAIL SERVICE */
function sendmail_service() { // call mailer REST API to send email
$_GET['APIKEY'] = "random_long_string_mailer_api_key";
ob_start(); include('/full_path_on_your_server/mailer.php');
$php_result = ob_get_contents(); ob_end_clean(); echo $php_result;
}
?>