Skip to main content
Inspiring
September 19, 2023
Answered

CF Scheduler - Repeating a task on exactly the same day of the month

  • September 19, 2023
  • 1 reply
  • 1309 views

(CF2016)

 

I need to run a task on the schedule on exactly the same day of the each month. I can set the start date this month, and lower down set MONTHLY, but does that mean it will litereally run on the same day of the month each day, it's not clear that will be the case

 

Thanks.,

    This topic has been closed for replies.
    Correct answer Charlie Arehart
    The answer is to use instead the available cron time feature in defining the scheduled task. It's not new (introduced in cf10) but many have never noticed it or didn't realize its capabilities.
     
    So first, the following would run every month on the 1st, at noon:
     
    0 0 12 1 * ? 
     
    While the cron time is documented a bit by Adobe, there's far more at the site of the scheduling engine which Adobe bundles, especially at http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html
     
    Even more helpful is a site showing a) dozens of examples (https://www.freeformatter.com/cron-expression-generator-quartz.html#cronexpressionexamples) and b) above that offering a quartz crontime generator. Sweet. 
     
    Finally, note that quartz crontime does differ from linux/UNIX crontime in having an extra seconds value as the first argument. So be careful finding any old cron time examples. 🙂 
     
    Let us know if this gets you going. 

    1 reply

    Charlie Arehart
    Community Expert
    Charlie ArehartCommunity ExpertCorrect answer
    Community Expert
    September 19, 2023
    The answer is to use instead the available cron time feature in defining the scheduled task. It's not new (introduced in cf10) but many have never noticed it or didn't realize its capabilities.
     
    So first, the following would run every month on the 1st, at noon:
     
    0 0 12 1 * ? 
     
    While the cron time is documented a bit by Adobe, there's far more at the site of the scheduling engine which Adobe bundles, especially at http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html
     
    Even more helpful is a site showing a) dozens of examples (https://www.freeformatter.com/cron-expression-generator-quartz.html#cronexpressionexamples) and b) above that offering a quartz crontime generator. Sweet. 
     
    Finally, note that quartz crontime does differ from linux/UNIX crontime in having an extra seconds value as the first argument. So be careful finding any old cron time examples. 🙂 
     
    Let us know if this gets you going. 

    /Charlie (troubleshooter, carehart. org)
    ACS LLCAuthor
    Inspiring
    September 19, 2023

    Thanks Charlie, that's a massive help, I did notice it but was not familiar with Quartz so ran in the other direction

    Using the Quartz generator I was able to create what I wanted, so if I want to run on the 28th of each month, I just add in 

    0 0 0 28 * ? *

     

    Just need to give it a month now to see if it works 😉

    Charlie Arehart
    Community Expert
    Community Expert
    September 19, 2023

    Glad to help, and yep that would be at midnight, if that's what you want (you hadn't said). And the last arg is optional, which is why my example didn't have it. But yep, cool stuff. Thanks for marking it as the answer. 

    /Charlie (troubleshooter, carehart. org)