Skip to content

Instantly share code, notes, and snippets.

@auxesis
Created June 27, 2011 02:08
Show Gist options
  • Select an option

  • Save auxesis/1048206 to your computer and use it in GitHub Desktop.

Select an option

Save auxesis/1048206 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# flock -e -w 0 200 - setup an exclusive lock around every command to be executed (we use fd 200).
# wait indefinitely until the lock is released before doing anything.
set -e
(
flock -e -w 0 200
# Put your commands here.
) 200>/tmp/cron.flock-$(basename $0)
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment