Monitoring Scheduled Jobs
Use healthchecks.io and Pushover to find out right away when a scheduled job fails, and by morning when one never ran
A scheduled job that crashes is easy to deal with, as long as you hear about it. The trouble is the job that quietly stops: the PC rebooted for an update, Task Scheduler didn't fire, or the script died with nobody watching. You find out days later, when the data you were counting on isn't there.
I monitor my scheduled jobs with healthchecks.io and get the alerts on my phone through Pushover. Between them they tell me two things:
A job never ran. healthchecks.io notices the job didn't report in on time, and alerts me then.
The free healthchecks.io plan monitors 20 jobs, which is plenty for most traders.
How it works
Every job you monitor is a check, and every check has its own ping URL, such as https://hc-ping.com/your-uuid-here. Your job calls that URL when it runs, and what you add to the end of the URL tells healthchecks.io what happened:
| Ping | Meaning | What healthchecks.io does |
|---|---|---|
https://hc-ping.com/your-uuid-here/start |
The job is starting | Starts timing the run |
https://hc-ping.com/your-uuid-here |
The job finished OK | Marks the check up and expects the next run on schedule |
https://hc-ping.com/your-uuid-here/fail |
The job finished and something broke | Marks the check down right away and sends alerts |
https://hc-ping.com/your-uuid-here/1 |
The job's exit code | /0 counts as success, any other number counts as a failure |
You also tell healthchecks.io how often the job should run and how long to wait, the grace time, before it decides a run is missing.
That gives you two separate ways to find out about a problem:
- The fail ping is the job telling you it broke. You hear about it immediately, without waiting for any timer.
- The missed ping is healthchecks.io noticing that the job went quiet. It catches what the job can't report: the PC was off, the task never started or the script hung. You hear about it once the grace time runs out.
The /start ping is optional
A job only needs to send the success or fail ping. Adding /start at the beginning gets you two more things:
- How long each run took. The check's event log shows the run time for every run, so you notice when a 2-minute job starts taking 40.
- Whether the job started at all. If a check goes down, a
startwith no finish after it means the job started and then hung or died. Nostartat all means it never ran. Those are different problems to go look for.
After a /start, healthchecks.io expects the finish ping within the grace time and marks the check down if it doesn't arrive. It costs one extra request per run, so I always send it.
Adding the pings to a job
The simplest way is a batch file that runs your job and passes its exit code along. curl comes with Windows 10 and 11:
curl -fsS -m 10 --retry 3 https://hc-ping.com/your-uuid-here/start
python important_job.py
curl -fsS -m 10 --retry 3 https://hc-ping.com/your-uuid-here/%ERRORLEVEL%
If important_job.py exits with 0, the last line pings /0 and the check stays up. If it exits with 1, the ping goes to /1 and the alert goes out.
In Python, you can send text with the ping too. healthchecks.io saves it in the check's event log, so when a job fails, the error is waiting for you there and you don't have to dig through log files on the PC:
import sys
import traceback
import urllib.request
PING_URL = "https://hc-ping.com/your-uuid-here"
def ping(suffix="", message=""):
try:
urllib.request.urlopen(PING_URL + suffix, data=message.encode(), timeout=10)
except OSError:
pass # a monitoring hiccup should never stop the job
def important_job():
# ... the actual work ...
return "Processed 1,240 rows"
ping("/start")
try:
summary = important_job()
except Exception:
ping("/fail", traceback.format_exc())
sys.exit(1)
ping("", summary)
The fail ping only goes out when the job knows something went wrong. If your job can "succeed" and still produce nothing useful, such as an empty output file, check for that in the job and raise an error, so it becomes a fail ping instead of a silent success.
Every five minutes
Say the important job runs every five minutes during the trading day. Set the check up with a simple schedule:
- Period: 5 minutes
- Grace time: 5 minutes
If a run fails, you hear about it within seconds. If the job stops running, you hear about it about 10 minutes after its last ping: the 5-minute period plus the 5-minute grace.
healthchecks.io alerts you when a check changes state, when it goes down and when it comes back up. It doesn't alert on every failed run. A job that fails 30 times in a row sends you one alert, not 30, and you get one more when it's fixed.
If the job only runs during market hours, give the check a cron schedule that matches the job's own, such as */5 9-15 * * 1-5 with the time zone set to America/New_York. Otherwise healthchecks.io alerts you every evening when the job stops on purpose.
Once a day
Now say the important job runs once a day, at 9:00 PM on weekdays. Use a cron schedule:
- Schedule:
0 21 * * 1-5 - Time zone:
America/New_York - Grace time: 10 hours
A failed run still alerts you right away, at about 9:00 PM. A run that never happens alerts you at 7:00 AM: 9:00 PM plus 10 hours. That's the trick to choosing the grace time for a daily job: pick it so the "never ran" alert arrives when you're up and can do something about it, not at 3 in the morning.
Set the time zone. Without it, healthchecks.io reads the schedule in UTC and your 9:00 PM job is expected at 4:00 or 5:00 PM.
Getting alerts on your phone with Pushover
healthchecks.io can alert you by email, Slack, Telegram, SMS and many other ways. I use Pushover because it's built for exactly this kind of alert:
- It's cheap. $4.99 once for each platform (iPhone, Android or desktop) after a 30-day free trial, with no subscription. That covers 10,000 messages a month, far more than you'll use.
- The alerts stand out. Pushover alerts come through the Pushover app, so they don't get buried in your email.
- You choose how loud each alert is. Pushover priorities run from silent to emergency. In healthchecks.io you can pick one priority for "down" alerts and another for "up" alerts, so a failure makes noise and the all-clear arrives quietly.
- Emergency priority repeats until you acknowledge it. For the job you can't afford to miss, Pushover plays a loud alert every 5 minutes until you tap acknowledge, so a failure can't slip by while you're away from your phone.
- Quiet hours. You can tell the Pushover app not to make noise overnight.
To connect them, install the Pushover app and create an account, then open your healthchecks.io project's Integrations page, add Pushover and follow the link to connect your Pushover account. Then make sure each check you care about has the Pushover integration turned on.
Letting Claude set it up
You don't have to set any of this up by hand. healthchecks.io has a Management API that creates, changes, pauses and deletes checks and reads their ping history, and Claude can use it for you.
- In healthchecks.io, open your project's Settings and create an API key in the API Access section. A read-only key can only look. A full-access key can also create and change checks, which is what setup needs.
- Save the key in a file on your PC, such as
C:\Users\you\.config\healthchecks\api_key, rather than pasting it into a chat. - Tell Claude Code, or Claude in the desktop app, where the key is and what you want:
My healthchecks.io API key is in C:\Users\you.config\healthchecks\api_key. Create a check called Important Job for important_job.py, which runs at 9:00 PM New York time on weekdays. Alert me by 7:00 AM if it doesn't run. Then add start, success and fail pings to the script.
Behind the scenes, Claude sends one request to https://healthchecks.io/api/v3/checks/ with the name, schedule, time zone and grace time, gets the new check's ping URL back, and adds the pings to your script. It can also set up the Windows Task Scheduler task that runs the job.
Once your jobs are monitored, Claude can use the same API to answer questions like "Did all my jobs run last night?" or "Why is Important Job down?" by reading the checks and their ping history, including the error text your job sent with its fail ping.
Before you rely on it
- Make every job send a fail ping or a non-zero exit code when it breaks, not just a success ping when it works.
- Choose each grace time so the "never ran" alert arrives when you can act on it.
- Set the time zone on every cron schedule.
- Test it once: make the job fail on purpose and check that the alert reaches your phone.