Getting started
PHP Cron Job Monitoring
PHP powers a massive portion of the web. It is robust and easy to deploy, but traditional PHP cron jobs can be opaque when they fail. You shouldn’t have to dig through server error logs to know if a job missed its schedule.
At olic.io, we rely on a simple “ping.” Your PHP script sends a GET request to our server upon completion. It is a zero-dependency way to verify success.
Adding a Heartbeat to Your PHP Script
You can use cURL if you want detailed control, but for pure simplicity, PHP’s native file_get_contents is the fastest way to implement a monitor.
Implementation
<?php
// Your unique olic.io URL
$heartbeat_url = "https://api.olic.io/ping/YOUR-ID-HERE";
try {
// --- YOUR CORE LOGIC HERE ---
// echo "Generating reports...";
// ----------------------------
// Send the success ping
file_get_contents($heartbeat_url);
echo "Ping sent to olic.io";
} catch (Exception $e) {
// Handle your errors
echo "Job failed: " . $e->getMessage();
exit(1);
}
?>
This setup fits perfectly into the Easy configuration philosophy. You don’t need to configure an agent on your server; you just copy this snippet into your script.
Why PHP for Backend Automation
PHP is legendary for its “deploy and forget” stability. It is widely used by Marketing agencies for Sending newsletters at scheduled times or generating invoices.
The language is synchronous and predictable, making it excellent for linear tasks like Generating reports. However, execution time limits (max_execution_time) can sometimes kill a script silently. By placing the olic.io ping at the very end of your logic, you guarantee that the notification only triggers if the script survived the entire execution window.