Created
March 31, 2014 13:02
-
-
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…
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 | |
# 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