Skip to content

Instantly share code, notes, and snippets.

@dorentus
Created July 17, 2014 03:46
Show Gist options
  • Save dorentus/fa56408220aec640eca4 to your computer and use it in GitHub Desktop.
Save dorentus/fa56408220aec640eca4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rb-inotify'
if ARGV.count < 3
puts "Usage: #{File.basename $0} <path> <signal> <cmd>"
exit 1
end
path = ARGV[0]
signal = ARGV[1].to_sym
cmd = ARGV[2]
notifier = INotify::Notifier.new
notifier.watch path, signal do |event|
system cmd
end
notifier.run
@dorentus
Copy link
Author

http://fortune.106.187.88.242.xip.io

watch-and-run /var/opt/sites/any.xip.io/public/index.txt access "/usr/games/fortune -s > /var/opt/sites/any.xip.io/public/index.txt"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment