Cron jobs that never stack on top of each other
My 5-min sync job ran long, second copy started, they fought, load hit 8. Lock it:
— Wrap with flock: * * * * * flock -n /tmp/sync.lock /usr/bin/php /var/www/sync.php
— -n means if the lock's held, just skip this run silently
— Stop the cron-spam email flood: add MAILTO="" at the top, or append >/dev/null 2>&1
— Always use absolute paths — cron has almost no PATH, php alone fails
One lock file ends the pile-up. Try it tonight.
Root Access Daily
@RootAccessDaily
Cron jobs that never stack on top of each other
Этот пост опубликован в Telegram-канале Root Access Daily. Подписаться можно по ссылке: @RootAccessDaily.