Stop cron jobs from stacking on top of each other
Your 5-min sync takes 6 minutes one day and now two copies fight over the DB. Wrap it in flock.
— * * * * * /usr/bin/flock -n /tmp/sync.lock /usr/local/bin/sync.sh
The -n means: if the previous run still holds the lock, just skip this tick. No pileups, no doubled writes, no slow-march to OOM. One word in your crontab saves you a 3am incident. Works for backups, imports, anything that can run long. Try it tonight.
Root Access Daily
@RootAccessDaily
Stop cron jobs from stacking on top of each other
Этот пост опубликован в Telegram-канале Root Access Daily. Подписаться можно по ссылке: @RootAccessDaily.