Created
July 26, 2013 08:29
-
-
Save sideshowcoder/6087223 to your computer and use it in GitHub Desktop.
run only once script in ruby
This file contains 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
require 'fileutils' | |
exit if FileTest.exist?('lock.file') | |
# create a lock | |
FileUtils.touch('lock.file') | |
# do some work | |
sleep 30 | |
# free the lock | |
FileUtils.rm('lock.file') | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment