Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A cron job script to capture computer activity every 30 seconds
# computer activity data collection for
# 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')
sleep 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment