32

Curious what everyone's approach is for handling cron jobs that depend on external APIs.

Had a data sync job that pulled from a vendor API every hour. Worked great for months until the vendor started rate-limiting us during peak hours. The job would fail, retry on the next cron tick, hit the rate limit again, and basically spin for 3-4 hours until traffic died down.

What I ended up doing was adding exponential backoff inside the job itself — first retry after 5 min, then 15, then 60. But it felt wrong because now the job's execution time is unpredictable and can overlap with the next scheduled run.

The other approach I considered was just letting it fail and having a separate "catch-up" job that runs less frequently and handles any gaps. Cleaner separation but more moving parts.

For those of you running scheduled jobs that depend on third-party services: do you build the retry logic into the job, handle it at the scheduler level, or just accept that some runs will fail and deal with it downstream?

Also wondering if anyone's hit issues with jobs that silently succeed but return partial data — like the API responds 200 but only gives you half the records because of an undocumented pagination change. That one took me a while to catch.

you are viewing a single comment's thread
view the rest of the comments
[-] Skullgrid@lemmy.world 18 points 3 weeks ago

Have it put information about last run details in a persistent file. When the cron job runs again, check the file first to know how the next iteration should run.

this post was submitted on 18 Sep 2026
32 points (97.1% liked)

Programming

28776 readers
825 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 3 years ago
MODERATORS