Created
October 4, 2013 17:44
-
-
Save anonymous/6829782 to your computer and use it in GitHub Desktop.
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
1380908555 hi 6 | |
1380908555 hi 6 | |
1380908612 filegrapher.rb 552 | |
1380908612 filegrapher.rb 552 | |
1380908647 hi 1440 | |
1380908647 hi 1440 |
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
#!/usr/bin/env ruby | |
# gems required - rb-inotify | |
require 'rb-inotify' | |
def handler(event) | |
File.open("data", "a") { |f| f.write "#{Time.now.to_i} #{event.absolute_name} #{File.size event.absolute_name}\n" } | |
end | |
notifier = INotify::Notifier.new | |
files = File.readlines('FILES').map { |a| a.strip! } | |
files.each do |file| | |
p "watching #{file}" | |
begin | |
notifier.watch file, :modify, :create, :delete, :delete_self do |event| | |
$stderr.puts event.absolute_name | |
handler event | |
end | |
rescue | |
p "error watching #{file}" | |
end | |
end | |
notifier.run |
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
filegrapher.rb | |
test | |
hi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment