flock -n /tmp/job.lock -c 'command'

Category: Cron & Scheduling

flock -n /tmp/job.lock -c 'command'

Run cron job with file lock to prevent parallel runs

Runs a cron job with a file lock: if the previous run is still going, this new run is skipped. Prevents overlapping jobs.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.