[{"data":1,"prerenderedAt":545},["ShallowReactive",2],{"\u002Fblog\u002Fheartbeat-monitoring-cron-jobs":3},{"id":4,"title":5,"author":6,"body":8,"category":534,"date":535,"description":536,"extension":537,"image":538,"lastUpdated":539,"meta":540,"navigation":99,"path":541,"readingTime":133,"seo":542,"stem":543,"__hash__":544},"blog\u002Fblog\u002Fheartbeat-monitoring-cron-jobs.md","Heartbeat Monitoring for Cron Jobs and Workers",{"name":7},"Vantaj Team",{"type":9,"value":10,"toc":513},"minimark",[11,16,20,28,31,35,38,54,157,164,168,171,176,179,183,186,190,193,197,200,204,207,211,214,218,221,291,294,298,301,308,369,372,376,380,386,451,455,458,481,485,488,492,495,499,506,509],[12,13,15],"h2",{"id":14},"what-is-heartbeat-monitoring","What Is Heartbeat Monitoring?",[17,18,19],"p",{},"Traditional uptime monitoring works by sending requests to your service and checking for a response. But not all critical processes are web-facing. Database backups, queue workers, scheduled reports, data pipelines - these are background jobs that run on a schedule, and when they silently stop working, nobody notices until it's too late.",[17,21,22,23,27],{},"Heartbeat monitoring flips the model. Instead of Vantaj pinging your service, ",[24,25,26],"strong",{},"your service pings Vantaj",". If we don't receive a ping within the expected interval, we know something went wrong and alert you immediately.",[17,29,30],{},"It's the difference between checking if someone is home (uptime monitoring) and expecting a daily phone call that never comes (heartbeat monitoring).",[12,32,34],{"id":33},"how-it-works","How It Works",[17,36,37],{},"The concept is simple:",[39,40,41,45,48,51],"ol",{},[42,43,44],"li",{},"You create a heartbeat monitor in Vantaj and get a unique endpoint URL",[42,46,47],{},"Your cron job or worker sends an HTTP request to that URL when it completes successfully",[42,49,50],{},"Vantaj tracks the timing of each ping",[42,52,53],{},"If a ping doesn't arrive within the expected window, Vantaj triggers an alert",[55,56,61],"pre",{"className":57,"code":58,"language":59,"meta":60,"style":60},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# Add this to the end of your cron job\ncurl -fsS --retry 3 https:\u002F\u002Fapi.vantaj.co\u002Fheartbeat\u002Fyour-heartbeat-id\n\n# Or in a Node.js worker\nawait fetch('https:\u002F\u002Fapi.vantaj.co\u002Fheartbeat\u002Fyour-heartbeat-id')\n\n# Or in a Python script\nimport requests\nrequests.get('https:\u002F\u002Fapi.vantaj.co\u002Fheartbeat\u002Fyour-heartbeat-id')\n","bash","",[62,63,64,73,94,101,107,126,131,137,146],"code",{"__ignoreMap":60},[65,66,69],"span",{"class":67,"line":68},"line",1,[65,70,72],{"class":71},"sHwdD","# Add this to the end of your cron job\n",[65,74,76,80,84,87,91],{"class":67,"line":75},2,[65,77,79],{"class":78},"sBMFI","curl",[65,81,83],{"class":82},"sfazB"," -fsS",[65,85,86],{"class":82}," --retry",[65,88,90],{"class":89},"sbssI"," 3",[65,92,93],{"class":82}," https:\u002F\u002Fapi.vantaj.co\u002Fheartbeat\u002Fyour-heartbeat-id\n",[65,95,97],{"class":67,"line":96},3,[65,98,100],{"emptyLinePlaceholder":99},true,"\n",[65,102,104],{"class":67,"line":103},4,[65,105,106],{"class":71},"# Or in a Node.js worker\n",[65,108,110,113,116,120,123],{"class":67,"line":109},5,[65,111,112],{"class":78},"await",[65,114,115],{"class":82}," fetch",[65,117,119],{"class":118},"sMK4o","(",[65,121,122],{"class":78},"'https:\u002F\u002Fapi.vantaj.co\u002Fheartbeat\u002Fyour-heartbeat-id'",[65,124,125],{"class":118},")\n",[65,127,129],{"class":67,"line":128},6,[65,130,100],{"emptyLinePlaceholder":99},[65,132,134],{"class":67,"line":133},7,[65,135,136],{"class":71},"# Or in a Python script\n",[65,138,140,143],{"class":67,"line":139},8,[65,141,142],{"class":78},"import",[65,144,145],{"class":82}," requests\n",[65,147,149,152,154],{"class":67,"line":148},9,[65,150,151],{"class":78},"requests.get(",[65,153,122],{"class":78},[65,155,125],{"class":156},"sTEyZ",[17,158,159,160,163],{},"The key detail: you only send the heartbeat ",[24,161,162],{},"after"," the job completes successfully. If the job crashes mid-execution, no heartbeat is sent, and Vantaj catches the failure.",[12,165,167],{"id":166},"when-you-need-heartbeat-monitoring","When You Need Heartbeat Monitoring",[17,169,170],{},"Any process that runs on a schedule and doesn't have a public endpoint is a candidate. Here are the most common use cases:",[172,173,175],"h3",{"id":174},"database-backups","Database Backups",[17,177,178],{},"Your nightly database backup is one of the most critical jobs in your infrastructure. If it fails silently for a week, you won't know until you actually need to restore - and by then it's a crisis. A heartbeat at the end of the backup script ensures you know the moment a backup doesn't complete.",[172,180,182],{"id":181},"queue-and-background-workers","Queue and Background Workers",[17,184,185],{},"Workers processing jobs from a queue (Sidekiq, Celery, BullMQ) can crash, deadlock, or run out of memory. Periodic heartbeats from each worker confirm they're alive and processing. If a worker goes silent, you can investigate before the queue backs up.",[172,187,189],{"id":188},"scheduled-reports-and-emails","Scheduled Reports and Emails",[17,191,192],{},"Daily digest emails, weekly analytics reports, monthly invoicing runs - these are jobs your business depends on but rarely thinks about until they break. A heartbeat after each successful send confirms delivery is happening on schedule.",[172,194,196],{"id":195},"data-sync-and-etl-pipelines","Data Sync and ETL Pipelines",[17,198,199],{},"Data pipelines that sync between databases, transform data, or push to warehouses are notoriously brittle. A heartbeat at the end of each pipeline run gives you confidence that data is flowing correctly.",[172,201,203],{"id":202},"health-check-scripts","Health Check Scripts",[17,205,206],{},"Custom scripts that verify application state - checking disk space, validating configuration, confirming third-party API connectivity - can report their status via heartbeat. If the script itself fails to run, the missing heartbeat catches it.",[172,208,210],{"id":209},"certificate-and-domain-renewal-jobs","Certificate and Domain Renewal Jobs",[17,212,213],{},"If you're using automated certificate renewal (certbot, ACME clients), a heartbeat after each renewal confirms the process completed. Combined with Vantaj's SSL monitoring, you get defense in depth.",[12,215,217],{"id":216},"setting-up-a-heartbeat-monitor","Setting Up a Heartbeat Monitor",[17,219,220],{},"Getting started takes less than a minute:",[222,223,224,237],"table",{},[225,226,227],"thead",{},[228,229,230,234],"tr",{},[231,232,233],"th",{},"Step",[231,235,236],{},"What to do",[238,239,240,251,261,271,281],"tbody",{},[228,241,242,248],{},[243,244,245],"td",{},[24,246,247],{},"1. Create",[243,249,250],{},"Add a new heartbeat monitor in your Vantaj dashboard",[228,252,253,258],{},[243,254,255],{},[24,256,257],{},"2. Name it",[243,259,260],{},"Give it a descriptive name (e.g., \"Nightly Postgres Backup\")",[228,262,263,268],{},[243,264,265],{},[24,266,267],{},"3. Set the interval",[243,269,270],{},"How often the job should run (every 5 min, hourly, daily, weekly)",[228,272,273,278],{},[243,274,275],{},[24,276,277],{},"4. Set the grace period",[243,279,280],{},"How long to wait past the expected time before alerting",[228,282,283,288],{},[243,284,285],{},[24,286,287],{},"5. Copy the URL",[243,289,290],{},"Add the heartbeat endpoint to your job's success handler",[17,292,293],{},"That's it. No agents to install, no SDKs to integrate, no configuration files to manage. One HTTP request at the end of your job is all it takes.",[12,295,297],{"id":296},"grace-periods-avoiding-false-alerts","Grace Periods: Avoiding False Alerts",[17,299,300],{},"Not every job runs at exactly the same time. A daily backup that usually finishes at 2:05 AM might occasionally take until 2:20 AM due to database load. Without a grace period, you'd get a false alert every time the job runs a little slow.",[17,302,303,304,307],{},"The ",[24,305,306],{},"grace period"," is the buffer time Vantaj waits after the expected window before firing an alert. Set it based on the normal variance of your job:",[222,309,310,323],{},[225,311,312],{},[228,313,314,317,320],{},[231,315,316],{},"Job Type",[231,318,319],{},"Typical Interval",[231,321,322],{},"Suggested Grace Period",[238,324,325,336,347,358],{},[228,326,327,330,333],{},[243,328,329],{},"Queue worker heartbeat",[243,331,332],{},"Every 5 minutes",[243,334,335],{},"2–3 minutes",[228,337,338,341,344],{},[243,339,340],{},"Hourly data sync",[243,342,343],{},"Every hour",[243,345,346],{},"10–15 minutes",[228,348,349,352,355],{},[243,350,351],{},"Daily backup",[243,353,354],{},"Every 24 hours",[243,356,357],{},"30–60 minutes",[228,359,360,363,366],{},[243,361,362],{},"Weekly report",[243,364,365],{},"Every 7 days",[243,367,368],{},"2–4 hours",[17,370,371],{},"The goal is simple: long enough to account for normal variance, short enough to catch actual failures quickly.",[12,373,375],{"id":374},"best-practices","Best Practices",[172,377,379],{"id":378},"only-heartbeat-on-success","Only Heartbeat on Success",[17,381,382,383,385],{},"Send the heartbeat ",[24,384,162],{}," your job completes successfully, not at the start. If you heartbeat at the beginning, a job that crashes halfway through still looks healthy to your monitor.",[55,387,389],{"className":57,"code":388,"language":59,"meta":60,"style":60},"# ✅ Correct - heartbeat after success\npg_dump mydb > backup.sql && curl -fsS https:\u002F\u002Fapi.vantaj.co\u002Fheartbeat\u002Fabc123\n\n# ❌ Wrong - heartbeat before the actual work\ncurl -fsS https:\u002F\u002Fapi.vantaj.co\u002Fheartbeat\u002Fabc123 && pg_dump mydb > backup.sql\n",[62,390,391,396,421,425,430],{"__ignoreMap":60},[65,392,393],{"class":67,"line":68},[65,394,395],{"class":71},"# ✅ Correct - heartbeat after success\n",[65,397,398,401,404,407,410,413,416,418],{"class":67,"line":75},[65,399,400],{"class":78},"pg_dump",[65,402,403],{"class":82}," mydb",[65,405,406],{"class":118}," >",[65,408,409],{"class":82}," backup.sql",[65,411,412],{"class":118}," &&",[65,414,415],{"class":78}," curl",[65,417,83],{"class":82},[65,419,420],{"class":82}," https:\u002F\u002Fapi.vantaj.co\u002Fheartbeat\u002Fabc123\n",[65,422,423],{"class":67,"line":96},[65,424,100],{"emptyLinePlaceholder":99},[65,426,427],{"class":67,"line":103},[65,428,429],{"class":71},"# ❌ Wrong - heartbeat before the actual work\n",[65,431,432,434,436,439,441,444,446,448],{"class":67,"line":109},[65,433,79],{"class":78},[65,435,83],{"class":82},[65,437,438],{"class":82}," https:\u002F\u002Fapi.vantaj.co\u002Fheartbeat\u002Fabc123",[65,440,412],{"class":118},[65,442,443],{"class":78}," pg_dump",[65,445,403],{"class":82},[65,447,406],{"class":118},[65,449,450],{"class":82}," backup.sql\n",[172,452,454],{"id":453},"add-retries-to-the-heartbeat-request","Add Retries to the Heartbeat Request",[17,456,457],{},"The heartbeat HTTP request itself can fail due to transient network issues. Add retries so a momentary blip doesn't cause a false alert:",[55,459,461],{"className":57,"code":460,"language":59,"meta":60,"style":60},"curl -fsS --retry 3 --retry-delay 5 https:\u002F\u002Fapi.vantaj.co\u002Fheartbeat\u002Fabc123\n",[62,462,463],{"__ignoreMap":60},[65,464,465,467,469,471,473,476,479],{"class":67,"line":68},[65,466,79],{"class":78},[65,468,83],{"class":82},[65,470,86],{"class":82},[65,472,90],{"class":89},[65,474,475],{"class":82}," --retry-delay",[65,477,478],{"class":89}," 5",[65,480,420],{"class":82},[172,482,484],{"id":483},"one-heartbeat-per-logical-job","One Heartbeat Per Logical Job",[17,486,487],{},"Don't combine multiple jobs into a single heartbeat. If your backup and your report both ping the same heartbeat, a failure in one might be masked by the other succeeding. Create separate heartbeat monitors for each critical job.",[172,489,491],{"id":490},"monitor-the-monitors","Monitor the Monitors",[17,493,494],{},"Heartbeat monitoring pairs perfectly with uptime monitoring. Use uptime checks for your public-facing services and heartbeats for your background jobs. Together, they give you complete visibility into your infrastructure's health.",[12,496,498],{"id":497},"why-vantaj-for-heartbeat-monitoring","Why Vantaj for Heartbeat Monitoring",[17,500,501,502,505],{},"Vantaj's heartbeat monitoring is designed with the same principles as the rest of the platform: ",[24,503,504],{},"simple setup, sensible defaults, and reliable alerting",". There are no agents to install, no complex configurations, and no hidden costs. Create a heartbeat, add a curl command to your job, and you're covered.",[17,507,508],{},"When a heartbeat goes missing, Vantaj's alerting pipeline ensures the notification reaches you - via email, Slack, Discord, webhook, or any combination. The same reliable, redundant infrastructure that powers our uptime monitoring backs every heartbeat alert.",[510,511,512],"style",{},"html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":60,"searchDepth":75,"depth":75,"links":514},[515,516,517,525,526,527,533],{"id":14,"depth":75,"text":15},{"id":33,"depth":75,"text":34},{"id":166,"depth":75,"text":167,"children":518},[519,520,521,522,523,524],{"id":174,"depth":96,"text":175},{"id":181,"depth":96,"text":182},{"id":188,"depth":96,"text":189},{"id":195,"depth":96,"text":196},{"id":202,"depth":96,"text":203},{"id":209,"depth":96,"text":210},{"id":216,"depth":75,"text":217},{"id":296,"depth":75,"text":297},{"id":374,"depth":75,"text":375,"children":528},[529,530,531,532],{"id":378,"depth":96,"text":379},{"id":453,"depth":96,"text":454},{"id":483,"depth":96,"text":484},{"id":490,"depth":96,"text":491},{"id":497,"depth":75,"text":498},"tutorials","2026-05-10","Ensure your background jobs, cron tasks, and workers run on schedule with heartbeat monitoring. Learn how it works, when to use it, and how to set it up.","md",null,"2026-06-04",{},"\u002Fblog\u002Fheartbeat-monitoring-cron-jobs",{"title":5,"description":536},"blog\u002Fheartbeat-monitoring-cron-jobs","LrDlN0Vi_8unHda0IGFDiBckv_E14D69fVTxaC4hasA",1780610160581]