Created
July 23, 2013 22:50
-
-
Save tubit/6066850 to your computer and use it in GitHub Desktop.
Create file lock on file to prevent concurrent script runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
DATA.flock(File::LOCK_EX | File::LOCK_NB) or abort "Already running." | |
trap("INT", "EXIT") | |
puts "Running..." | |
loop do | |
sleep | |
end | |
__END__ | |
DO NOT DELETE: used for locking |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment