Schedule App to start at random minute

Hi,
I would like to create a macro that starts an App every day between e.g. 13:30 and 13:45 at a random minute.

I found a way to schedule an App Start at an exact time using the Time of Day Trigger but have no idea how to achieve the random Minute.

If you show your macro, I can help you modify it to add the random 15 minutes. Or I can show you how I would do it, which may be different from how you want to do it.

There are a couple ways you could do this.

You could simply trigger the macro at 8:30 and then Pause for 60*RAND(16).

Alternatively, you could trigger your macro at 8:30 to 8:45 every minute, and then decide at random whether to execute or not, and only if it hadn't already executed that day.

This could be done, but it is quite complex. You use the DAY function to check if it is the same day as you previous executed, as well as whether you have executed today, and you have to also choose a random chance to execute which needs to increase each minute (so 1/16 chance at 8:30, 1/15 chance at 8:31, 1/14 at 8:32, … up to 1/1 at 8:45), presuming the macro has not already done its job today.

If you want me to elaborate on this further, I can do so.

Thanks all! I went with the Pause-Suggestion. Might not be the most performant, but for me, the least complex and comprehendible..

1 Like

In case others are interested, here's how the Macro (schedule the launch of MS-Teams at a random time between 8:30 and 8:40, Mon-Thur) looks:

CleanShot 2025-06-11 at 16.52.46

And here's a download:
Teams Scheduler.kmmacros (2.3 KB)

I ended up using cron to schedule this, so all my scheduling stays in one app and not scattered across multiple services. The cron-entry looks like this:
30 08 * * 1-4 /bin/sleep $((0 + $RANDOM \% 600)); open "/Applications/Microsoft Teams.app"