Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

cronlock: stop overlapping cron jobs with flock (plus timeout and failure webhooks)

Описание и применение

cronlock упрощает управление cron‑задачами, обеспечивая одновременное выполнение, таймауты, логирование и уведомления об ошибках.

Задача

Cron jobs can overlap if a job runs longer than its schedule, causing resource contention, corrupted data, or runaway processes.

Результат

cronlock simplifies cron job management by ensuring single instances, optional timeouts, logging, and failure notifications, reducing script complexity and errors.

Рабочий процесс

  • 1. Install cronlock by copying it to a directory in $PATH and making it executable.
  • 2. Use cronlock with desired options: --name, --timeout, --log, --notify, followed by the command to run.
  • 3. cronlock acquires an advisory lock with flock -n; if lock is held, it exits 0 and skips execution.
  • 4. If a timeout is set, cronlock runs the command via timeout, enforcing the limit.
  • 5. cronlock logs start and end timestamps and streams command output to the specified log file.
  • 6. If the command exits non‑zero, cronlock POSTs a JSON payload to the provided webhook URL.
  • 7. The script exits with the wrapped command’s exit code (or 0 if skipped).

Доказательства

Cron schedules tasks at fixed intervals. If a job runs longer than its interval, the next invocation starts before the previous one finishes.

Источник

cronlock ties all of those primitives together in a single, tiny wrapper.

Источник

cronlock [--name NAME] [--timeout SECONDS] [--log FILE] [--notify URL] -- COMMAND [ARGS...]

Источник

If another backup is still running when the next cron tick fires, cronlock simply exits 0 without starting a second copy.

Источник

  • Дата записи: 2026-10-14T19:56:05.197Z