Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Created March 31, 2014 13:02
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save emad-elsaid/9891800 to your computer and use it in GitHub Desktop.
Save emad-elsaid/9891800 to your computer and use it in GitHub Desktop.
Track your computer open/shutdown times this is a very simple script, i created to track when did i open and closes my computer, on the long run, i can read these data and analyse it to see detect my usage patterns and how to improve my computer usage for a better work/life balance. this script uses simple text file as log file, it write the eve…
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
FILENAME = 'db.txt'
OPEN, CLOSE = 1 , 0
file = File.open(FILENAME, 'a')
file.write "#{OPEN} : #{Time.new}\n"
file.flush
begin
loop { sleep 60 } # sleep for an hour in an endless loop
rescue SystemExit, Interrupt # on exit
file.write "#{CLOSE} : #{Time.new}\n"
file.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment