Cron job Monitoring.
How to send HTTP requests to heartbeat monitor?
Home / Help Center / Cron job monitoring
Cron job or heartbeat monitoring is a great way to monitor intranet servers/computers/devices which are connected to the internet.
And, besides that, it also allows us to monitor the health of the regular actions (cron jobs, background processes..) our website/app/system performs.
It works in an opposite way compared to the other monitoring types as it requires the monitor to send the requests so that Uptime Robot can decide if it is up or down.
And, for sending these regular HTTP requests you can use:
- Crontab (Unix/Linux)
In order to create/edit a cron job:
- connect to the server/computer with SSH
- type
crontab -e
- select the editor of choice from the displayed list
- Append the entry like:
*/5 * * * * wget --spider "https://heartbeat.uptimerobot.com/m794yyyyyyyy-xxxxxxxxxxxxxxx" >/dev/null 2>&1
by replacing the URL with the URL of the heartbeat monitor and also replacing the/5
part with the interval value of the monitor.
You can also try using the curl method:*/5 * * * * curl --insecure https://heartbeat.uptimerobot.com/m794yyyyyyyy-xxxxxxxxxxxxxxx >/dev/null 2>&1
- save and close the file (no need to restart)
- Task scheduler (Windows)
This built-in Windows feature allows triggering actions and programs every x minutes. Window's Powershell can easily send HTTP requests and they can both be used in combination to send regular HTTP requests with steps:
If you encounter a problem with PowerShell command related security/permission issue – where the task is scheduled to run as an admin with highest privilege, you have to add “-NoProfile -ExecutionPolicy Bypass” in the argument. Otherwise, the task itself will run successfully, but the actual PowerShell command included in the task would fail.- open the task scheduler app and create a new task
- make sure the task will run even if no user is logged-in:
- create a new trigger that will run every x minutes (where x must be the interval of the monitor):“Any time you edit the scheduled task, be sure to set the scheduled Trigger time to a future time - if you leave it set in the past it won't run.” When you create the task it defaults to the current time you hit “create task”. By the time you finish creating the task, that time has already past. You need to set the INITIAL start time to a few minutes ahead of the time it currently is when setting up the task.
- create a new action that will run Powershell to send HTTP requests and please enter the values:
- Program/script:
powershell.exe
- Add Arguments:
-Command "Invoke-WebRequest https://heartbeat.uptimerobot.com/m1616982-1d6f73e6a50d64d3491db9b3e7009b4af279d1at"
(by replacing this URL with the URL of the heartbeat monitor)
- Program/script:
- click ok and save the scheduled task