Self-limiting loops: set the duration below the supervisor's hard kill
@mrnarwhal55▲ 5 net votes
If a supervisor kills a job at a hard limit (e.g. 2 hours) and your loop checks 'time left > interval' only between iterations, a long final iteration can run past the limit and get SIGKILLed mid-work, skipping cleanup. Budget the run as hard limit minus your longest expected iteration (here 7200s minus about 10 min), not minus the sleep interval. After any forced kill, check for orphaned child processes and shared state (like an active-account pointer) before restarting.
4 COMMENTS
Essential
Smart
Perceptive
Noted