Cron trigger: 1st june every 2 years

I am trying to add a cron trigger "1st june every 2 years". Looked all over the Internet and still can't figure out "every 2 years". thanks very much !

How about 0 0 12 1 6 ? /2

Take a look at Cron expression that runs for every 2 years - Stack Overflow

1 Like

hello @tiffle thank you for your post.
I found it but could not figure out why it does not work.

The third digit refers to the day of the month - in your expression you have “0” which clearly is incorrect. Did you try the string I gave? Although, since I’m not at my Mac I’m not able to try it myself!

1 Like

I am very sorry @tiffle to test your patience. It still does not work.

Annotations
1- is a snapshot of your post
2 and 3- my entry and the error message

thanks again

No problem - as I said I’m not at my Mac so I’m just guessing.

0 0 1 6 * 2023/2

which maps to;

  • Minute: 0
  • Hour: 0
  • Day of month: 1
  • Month: 6
  • Day of week: * (that’s any)
  • Year: 2023/2 (every other year starting 2023)
1 Like

Good question. I don't know how to plug this into a KM Cron trigger, because it's out of range, but this is the cron format that works in the CronMaker site that was within the site @tiffle posted:

0 0 0 1 6 ? 2023/2

At 12:00 AM, on day 1 of the month, only in June, every 2 years, 2023 through 9999

2 Likes

thank you @tiffle and @kcwhat . Still does not work in KM, although works on the Cronmaker site.

That's what I said in my post.

1 Like

yes, you are right. My comment was superfluous. Sorry

The format works on cron checkers but maybe it's boiled down to the cron implementation that's programmed within Keyboard Maestro. I don't know if there is such a thing. You would have to ask @peternlewis. I remember trying cron examples, years ago, and some formats didn't work within KM or I just didn't know enough to put it in a format that KM could use.

You missed my suggestion in post no. 6

1 Like

CleanShot 2023-06-24 at 18.48.21@2x

The KM wiki says “You can also add / and a number after a range to match every N'th value“ so maybe you have to use:

2023-2099/2

to achieve what you’re after? In other words every 2nd year in the range 2023 to 2099.

3 Likes

thank you so much ! you are a genius @tiffle and thanks again @kcwhat for all your input.

3 Likes

Nope - after guessing a bit I decided to read the KM wiki page :wink:

6 Likes

Ooooooooo!!!! That's how it's done! Good catch @tiffle!!!! That's happiness right there.

The Keyboard Maestro Wiki has the nuggets. Just have to read them.

4 Likes

Classic example of all of us learning together. Wonderful stuff.

3 Likes

Now back to Glastonbury :drum:

1 Like

You have a solution, and a good one at that, but I just want to point out that sometimes folks try too hard to find the perfect solution when there is a trivially good solution available.

In this case, just trigger every year and check that the YEAR() is odd (or even) and only do something if it is. It's not like you care whether Keyboard Maestro wastes a few microseconds of CPU every other years…

Also note that the trigger will only run if the Mac is awake at the time the trigger would fire.

4 Likes