Skip to content

Instantly share code, notes, and snippets.

@sideshowcoder
Created July 26, 2013 08:29
Show Gist options
  • Save sideshowcoder/6087223 to your computer and use it in GitHub Desktop.
Save sideshowcoder/6087223 to your computer and use it in GitHub Desktop.
run only once script in ruby
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