Best way to delay a script

Hey,
I have a script that I made that I want to run every 10 minutes or so, but I don’t know what the best way to do it would be. I know of delays, but have heard that those are processor intensive. I’ve also heard of cron jobs, but those arn’t very user friendly for if I want to give this script to others. I want it to be like Twitterific and GMail Notifier for example. Any suggestions would be helpful, thanks!

Hi,

the easiest way is is a scipt saved as stay open application with an idle handler,

on idle
    -- do something
    return 10 * minutes
end idle

the smartest way is a launchd agent, described here andhere.

In my installer this:

<key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>" & hr & "</integer> <key>Minute</key> <integer>" & mn & "</integer> </dict>
has to be replaced with:

<key>StartInterval</key> <integer>600</integer>

Seems you found a better answer than in this post: http://bbs.applescript.net/viewtopic.php?id=22081

If for whatever reason you would need to skip an idle handler, the least processor intensive pause would be:


repeat --until escape condition
-- set escape condition
-- your action
do shell script "sleep x"
end repeat