Aller au contenu
#0048
CronFiles

Cleanup jobs that schedule their own retirement

A customer churned. You promised to retain their data for 90 days, then delete it. Three months from now is hard to remember.

You create a managed cron entry the day they churn. Schedule: @daily. Command: an exec script that checks if their data still exists and deletes a slice each night so the load is gentle. expires_at: 95 days out, just past when the work should be done.

The job runs every night. Around day 90 it finds nothing left to delete and exits cleanly. On day 95 the entry removes itself. There's no calendar reminder, no annual cleanup-the-cleanups review, no zombie crontab line that survives the original engineer's tenure.

The cleanup runs nightly until the thing being cleaned is gone.