32
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 18 Sep 2026
32 points (97.1% liked)
Programming
28786 readers
116 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
Two ways I've handled this. If you have some orchestrator, like kubernetes, you can use the job feature to retry. In that case you just let the script exit with error status.
If we're staying with just cron and shell scripts, look at using flock(1) with timeout in a bash script (example). You can create a lock to prevent multiple copies running and it cleans up automatically. You can combine this with time-stamped files to enforce a minimum amount of time since last run, or whatever you like.
I prefer having the retry handled outside the job itself, but I've used both approaches. I've grown to prefer separating the code for "doing the thing" from the code for "orchestrating the thing", but it depends on what environment it runs in, how critical it is, and how who else may be supporting it.
Finally, set up something to monitor it and alert you if it hasn't run successfully for some time.