Skip to content

Instantly share code, notes, and snippets.

@ChrisMacNaughton
Last active January 2, 2016 17:39
Show Gist options
  • Save ChrisMacNaughton/8338278 to your computer and use it in GitHub Desktop.
Save ChrisMacNaughton/8338278 to your computer and use it in GitHub Desktop.
require 'absolute_time'
last_checked = 0.0
thread = Thread.new do
%x{ Shell command here }
end
while true
now = AbsoluteTime.now.to_f
if now.to_i > last_checked.to_i
File.open('some-file.txt', 'a') { |f| f.write(0)}
last_checked = now
end
break unless thread.status
sleep(0.1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment