Idle time recorder

I’m try to create the ‘Idle time recorder’ in my mac. I have done it partially. But I can’t run this script automatically. Kindly go throw the below code and help on this topic.

set mytime to 0
delay 300
set mytime to "5"
do shell script "/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'"

set msg to "no"
tell application "Finder"
	if exists POSIX file "/Volumes/HDD1/Users/Shared/temp/idle/IdleTime.txt" then
		do shell script "echo '5'   >> /Volumes/HDD1/Users/Shared/temp/idle/IdleTime.txt"
		do shell script "echo " & quoted form of mytime & " >> /Volumes/HDD1/Users/Shared/temp/idle/IdleTime.txt"
	end if
end tell

I’m try to use ‘contab -e [path]’, but, this method also not support effectively.

Thanks in advance,

Don’t use do shell script in an tell application Finder blocks. Mac OS X is more strict about this since Mac OS X 10.6

Hi DJ Bazzie Wazzie,
Acknowledged, thanks for the suggestion.

Can anyone share the alternate code for ‘get ideal time’?

do shell script "/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'"

Additionally, advice to me ‘how to achieve this concept’ with applescript.