The Hummingbird's Heartbeat: On Building a Tiny Status Check for Your Smallest Service
We talk a lot about monitoring the big things. We watch for the roar of the database server, the heave of the application node, the steady flow of the network pipe. But what about the quiet ones? The little Perl script that tidies up old files at 3 AM, the Python utility that sends a daily summary email, the tiny Go service that acts as a bridge between two legacy systems. These hummingbirds of our infrastructure are easy to overlook until their silent, vital work suddenly stops.
You could install a full-blown monitoring suite, but that feels like building a watchtower to guard a garden shed. The complexity outweighs the task. Instead, I want to share a technique so simple it feels like cheating: the self-reporting status file. It’s a method that relies on the most boring, reliable technology of all: the filesystem and a cron job.
Here’s how it works. At the end of your small service’s successful run, its very last act is to touch a file. Not to write a novel to a log, not to send a complex event to a queue. Just to update the modification timestamp of a single, specific file on disk. For example, your email script would end with a simple touch /var/run/service-status/daily_email.ok.
The Watchful Eye
Now, for the watchful eye. This is the other half of the heartbeat. In another cron job—perhaps running every hour—you place a simple shell script. Its job is not to check if the process is running, but to check if it has recently done its work. It checks the age of that status file.
The script can be as simple as:
if [ -f /var/run/service-status/daily_email.ok ] && find /var/run/service-status -name "daily_email.ok" -mmin -1440 | grep -q .; then
echo "OK: Daily email has run in the last 24h"
else
echo "CRITICAL: Daily email has not run successfully today!" | mail -s "Alert: Email Service" admin@example.com
fi
This checks for the existence of the file and confirms it’s been modified in the last 1440 minutes (24 hours). If it finds it, all is well. If it doesn’t, it sends you an alert. The beauty is in its passivity. You’re not monitoring process tables; you’re monitoring proof of work.
This technique transforms an abstract worry—“is that thing still working?”—into a concrete, verifiable fact. The timestamp is the hummingbird’s heartbeat, a tiny, regular pulse that says, "I was here. I did my job." It’s a small pact between your service and your operations sense, a whisper of reliability in the vast silence of your systems. It’s the most boring kind of magic, and it works.
Notes & further reading
A few pages I came back to while writing this: