<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jeninho</title>
    <description>The latest articles on DEV Community by Jeninho (@jeninho).</description>
    <link>https://dev.to/jeninho</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3849857%2F82b559a1-960c-402c-9452-5d97f73a2b58.png</url>
      <title>DEV Community: Jeninho</title>
      <link>https://dev.to/jeninho</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jeninho"/>
    <language>en</language>
    <item>
      <title>Why Your Cron Jobs Fail Silently (And the Fix That Takes 30 Seconds)</title>
      <dc:creator>Jeninho</dc:creator>
      <pubDate>Mon, 06 Apr 2026 11:51:24 +0000</pubDate>
      <link>https://dev.to/jeninho/why-your-cron-jobs-fail-silently-and-the-fix-that-takes-30-seconds-3m8</link>
      <guid>https://dev.to/jeninho/why-your-cron-jobs-fail-silently-and-the-fix-that-takes-30-seconds-3m8</guid>
      <description>&lt;p&gt;Your database backup runs every night at 2 AM.&lt;br&gt;
Your invoice generator fires every Monday.&lt;br&gt;
Your cache warmer runs every 5 minutes.&lt;/p&gt;

&lt;p&gt;They all work great. Until they don't.&lt;/p&gt;

&lt;p&gt;And nobody notices.&lt;/p&gt;
&lt;h2&gt;
  
  
  The problem with cron jobs
&lt;/h2&gt;

&lt;p&gt;Cron jobs fail the same way they succeed: silently. The daemon doesn't&lt;br&gt;
care. There's no browser to show an error page. No user gets a 500.&lt;br&gt;
The only signal that something went wrong is the absence of something&lt;br&gt;
happening.&lt;/p&gt;

&lt;p&gt;Here's a scenario that plays out somewhere every week:&lt;/p&gt;

&lt;p&gt;A nightly pg_dump backup job runs at 02:00 UTC. One Tuesday, the Postgres&lt;br&gt;
server moves to a new port after an upgrade. The cron job fails with&lt;br&gt;
"connection refused" — but since nobody redirected stderr anywhere, the&lt;br&gt;
error vanishes. Three weeks later, a developer drops a table by accident,&lt;br&gt;
reaches for the backup, and finds the most recent one is 21 days old.&lt;/p&gt;

&lt;p&gt;That's the cost of an unmonitored cron job.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why traditional monitoring misses this
&lt;/h2&gt;

&lt;p&gt;Most monitoring tools watch for things that ARE happening: high CPU,&lt;br&gt;
slow responses, error rate spikes.&lt;/p&gt;

&lt;p&gt;Cron job failures are passive. They're the absence of something happening.&lt;br&gt;
Your APM won't alert you that a script didn't run. Your error tracker&lt;br&gt;
can't capture an exception from a process that never started.&lt;/p&gt;
&lt;h2&gt;
  
  
  The fix: dead man's switch monitoring
&lt;/h2&gt;

&lt;p&gt;The fix is simple in concept. Instead of watching for failure, you watch&lt;br&gt;
for the absence of success.&lt;/p&gt;

&lt;p&gt;Your job sends an HTTP request to a monitoring service every time it&lt;br&gt;
completes successfully. The service expects that ping at the configured&lt;br&gt;
interval. If it doesn't arrive, you get alerted.&lt;/p&gt;

&lt;p&gt;This catches everything:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Job crashes before completing&lt;/li&gt;
&lt;li&gt;Job never starts (crontab cleared, crond stopped)&lt;/li&gt;
&lt;li&gt;Job hangs and never finishes&lt;/li&gt;
&lt;li&gt;Disk full, preventing the job from writing its output&lt;/li&gt;
&lt;li&gt;Server rebooted, job never ran during boot sequence
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Before: no monitoring&lt;/span&gt;
0 2 &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; /usr/local/bin/backup.sh

&lt;span class="c"&gt;# After: 30 seconds to add monitoring&lt;/span&gt;
0 2 &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; /usr/local/bin/backup.sh &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://api.getcronsafe.com/ping/your-monitor-slug
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; is important: the ping only fires if the job exits with code 0.&lt;br&gt;
A failed job won't ping, which triggers the "missing ping" alert.&lt;/p&gt;
&lt;h2&gt;
  
  
  Going further: explicit failure reporting
&lt;/h2&gt;

&lt;p&gt;Basic heartbeat monitoring catches "job didn't run." But what about "job&lt;br&gt;
ran but reported an error"?&lt;/p&gt;

&lt;p&gt;You can send an explicit fail ping when your script detects a problem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; /usr/local/bin/backup.sh&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://api.getcronsafe.com/ping/backup"&lt;/span&gt;
&lt;span class="k"&gt;else
  &lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://api.getcronsafe.com/ping/backup?status=fail&amp;amp;output=backup_failed"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This fires an immediate alert without waiting for a timeout, and includes&lt;br&gt;
context about what went wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same pattern in Python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run_backup&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="c1"&gt;# your backup logic here
&lt;/span&gt;    &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;run_backup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://api.getcronsafe.com/ping/nightly-backup&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://api.getcronsafe.com/ping/nightly-backup&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;fail&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;output&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)},&lt;/span&gt;
        &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What to monitor
&lt;/h2&gt;

&lt;p&gt;Any scheduled process that runs unattended:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Database backups&lt;/strong&gt; — the most common silent failure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email queues&lt;/strong&gt; — stop processing and nobody complains for days&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data syncs&lt;/strong&gt; — your dashboard shows stale numbers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Certificate renewals&lt;/strong&gt; — the cert expires and your site shows a warning&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cleanup jobs&lt;/strong&gt; — when they stop, other services start crashing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tools for heartbeat monitoring
&lt;/h2&gt;

&lt;p&gt;Several services do this well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Healthchecks.io&lt;/strong&gt; — open source, self-hostable, free for 20 monitors&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cronitor&lt;/strong&gt; — mature platform, broader feature set, priced for teams&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://getcronsafe.com" rel="noopener noreferrer"&gt;CronSafe&lt;/a&gt;&lt;/strong&gt; — what I built: hosted, 20 monitors free, unlimited at
€9/month, with overlap detection and job output in alerts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three use the same core concept. Pick the one that fits your setup.&lt;/p&gt;




&lt;p&gt;The pattern is simple. The setup takes 30 seconds per job. The peace of&lt;br&gt;
mind is worth it.&lt;/p&gt;

&lt;p&gt;What are you currently using to monitor your cron jobs?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you want to try heartbeat monitoring without setting anything up yourself,&lt;br&gt;
CronSafe has a free plan with 20 monitors and no credit card required →&lt;br&gt;
&lt;a href="https://getcronsafe.com" rel="noopener noreferrer"&gt;getcronsafe.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>monitoring</category>
      <category>showdev</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
