Prevent two copies of a cron job from running simultaneously. flock takes an FD to a lock file; if the lock is held, the second invocation exits immediately.
Make sure only one copy of a long-running cron job runs at a time. Uses a non-blocking advisory lock on a sentinel file — second invocation exits immediately if the lock is held.
A single-file counter that survives concurrent increments correctly using flock + read-modify-write inside the locked region. Useful for crude visitor or job-id counters when you don't want a DB.