Sidebar

How to run a Cron string every other Friday?

0 votes
1.7K views
asked May 19, 2016 by mike-r-7535 (13,830 points)
Can someone give me a clue what would be the cron string to run the immunization batch sender every other Friday?

0 0 17 * * FRI

I’ve tried several things, none of which have worked?

2 Answers

0 votes
 
Best answer

CRON strings have their limitations.  One limitation is that to accurately get every other Friday, you would need to do calendar math to account for the months with odd number of days, including leap day.

As a makeshift solution, you can do every "even" Friday with this CRON String:

0 0 17 0/2 * FRI

Note, this CRON will have back to back Fridays on some months (August 26, September 2), and will have every third Fridays on other months (May 20, June 10).  If a precise "every other Friday" is needed, it should be programatically handled in a custom script where you can do calendar math.

answered May 19, 2016 by mike-r-7535 (13,830 points)
selected Apr 21, 2017 by brandon-w-8204
0 votes

Sample script to using calendar math:

var day = qie.formatDate('D');
if (!day%2) {
   //do the query with qie.doQuery
   var results = qie.doquery('db', 'query');
   //note you can do a for loop and add each individual record.
   qie.addInboundMessage(results, null);
}

Screenshot of setup:

answered Apr 21, 2017 by brandon-w-8204 (33,270 points)
...