try
-- Get the last time the script was run
set lastRun to date (do shell script "defaults read com.myDomainName.myScriptName last_time")
on error
-- Prefs file doesn't exist yet! Create it.
do shell script "defaults write com.myDomainName.myScriptName last_time " & (quoted form of (((current date) - 1 * days) as text))
-- and set a value for last run that is one day old.
set lastRun to (current date) - 1 * days
end try
-- test how old the last run was
if ((current date) - lastRun) > 10 then
-- and run the routine if it was more than [x] seconds old
beep 2
-- insert your notification routine here
-- finally, write the current time out to the prefs file
do shell script "defaults write com.barryw.myscript last_time " & (quoted form of ((current date) as text))
end if