Created
January 7, 2013 18:43
-
-
Save jehiah/4477372 to your computer and use it in GitHub Desktop.
A cron job script to capture computer activity every 30 seconds
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
#!/bin/sh | |
# computer activity data collection for http://jehiah.cz/one-two/ | |
# by Jehiah Czebotar | |
FILE="activity_log/`date +%Y%m%d`.log" | |
function log_activity() | |
{ | |
local UTC=`date "+%s,%Z"` | |
local IDLE=$((`/usr/sbin/ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/!{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000 )) | |
local ACTIVE_PROGRAM=$(/usr/bin/osascript -e 'tell application "System Events"' -e 'set frontApp to name of first application process whose frontmost is true' -e 'end tell') | |
echo "$UTC,$IDLE,$ACTIVE_PROGRAM" >> $FILE | |
} | |
log_activity | |
sleep 30 | |
log_activity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment