When using cron to auto-deploy with a bash script, concurrent runs can collide if the job takes longer than the cron interval. The `flock` command solves this by acquiring an exclusive file lock before running the script. With the `-n` (non-blocking) flag, any subsequent cron invocation that fires while the lock is held simply exits immediately rather than queuing up. Adding a `timeout` command alongside `flock` also guards against the deploy script hanging indefinitely. This pattern is useful for homelab setups that pull from GitHub on a schedule instead of using webhooks.
Sort: