Announcement

Collapse
No announcement yet.

Scheduled Job wrong scheduling

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scheduled Job wrong scheduling

    Hi! I have a custom scheduled job. Here is a cron I have set for it "0 10 */2 * 1-5"
    As label says, it should run every 2 days, but actually it runs every day. Am I missconfigured something or cron is wrong?
    EspoCRM ver. 8.1.1, php 8.3, ubuntu 22.04

    Click image for larger version

Name:	image.png
Views:	199
Size:	85.4 KB
ID:	102285

  • #2
    Hi,

    We use cron-expression library that determines when to run a job the next time. https://github.com/espocrm/espocrm/b...essor.php#L148

    Better specify exact days using comma. Your expression is ambiguous.

    Comment


    • #3
      I changed cron expression to '0 10 */2 * 1,2,3,4,5'
      And it scheduled next run for tomorrow. So there are 2 problems. 1 - it runs every day (but should every 2 day). 2 - it doesn't follow working days rule

      Comment


      • #4
        I'm not really good at reading code about the included versions. So you include versions of cron-expression starting with 3.0`?

        Latest version is 3.3.3

        Change log has some fixes regarding time and time zones.

        CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due - dragonmantank/cron-expression

        Comment


        • #5
          Why just not using "0 10 * * 1,3,5" notation, to prevent ambiguously between days of week, and 2-day interval. There are 7 days per week, 7 is not even number.

          Comment


          • #6
            I didn't think about this way. It works, many thanks!

            Comment


            • #7
              Note that the label does not give 100% guarantee that it will work exactly as it says. These are handled by different libs, backend and frontend.

              Comment


              • #8
                Commend from the discussion on the cron-expression repository:

                "The important thing to note (which isn't readily apparent) is that Day of Week and Day of Month combine their results when both are specified, which is how the original C implementation is designed. ... So the important thing to note in the translation is the and on Monday ... so you will run every day of 1-7 of the month, and all Mondays. This trips up a lot of people.​​"

                Comment

                Working...
                X