A scheduled job may still be running when its next interval arrives. Without coordination, overlapping copies can duplicate work or compete for the same records.
IN THIS ARTICLE
What you need before you begin
Measure the normal and worst-case duration and identify the scheduler’s timezone. Determine whether more than one server or scheduler can launch the task.
01 Schedule application jobs without overlapping runs
Use a scheduler or application lock that fits the deployment. A multi-server task needs a shared coordination mechanism when only one run should execute.
Define what happens when a previous run remains active: skip, queue or resume work deliberately. Avoid launching unlimited copies.
Set a realistic execution timeout and recoverable progress checkpoints. Make record processing tolerate a restart without repeating completed external actions.
Keep the lock ownership and expiry behavior safe for a long or failed run. Verify the old process is no longer active before manually removing a lock.
Log start, completion, duration and safe progress identifiers. Alert when expected completion is missed rather than only checking that cron launched.
02 Example: prevent a local scheduled report from overlapping
On a single Linux server that provides flock, a private lock can stop a second scheduled copy of the same report. Create the private lock directory through your normal deployment setup and replace every example path with the approved account paths.
/usr/bin/flock --nonblock /home/ACCOUNT/private/report.lock \
/home/ACCOUNT/apps/reports/.venv/bin/python \
/home/ACCOUNT/apps/reports/build_report.py
This command skips starting another copy when the lock is held. The example report must have a harmless staging mode for verification. Record skipped runs and completion separately. All launch paths must use the same lock, and a local file lock does not coordinate different hosting servers or every network filesystem.
Expected result: Starting the controlled job twice produces one active run and one visible lock refusal. After the first process exits, the next scheduled run can acquire the lock without manually deleting a still-active lock file.
Confirm the expected result
Run a controlled task longer than its interval in staging and confirm no unintended overlap occurs. Restart a worker and verify the recovery path.
Troubleshoot unexpected results
Repeated overlapping runs can make a formerly fast job slower through contention. Increasing frequency usually worsens that condition.
A common question
Does setting one cron entry guarantee one running copy?
No. Cron can start a new process at each scheduled time while the earlier process continues. Use the application or scheduler’s explicit overlap controls where needed.