Schedule Expression

  • Last update:December 11, 2020
  • I. Overview

    The settings of execution time is necessary for scheduled tasks. However, if the time conditions to execute a task is quite complicated, expressions are applied to handle these scenarios. For those frequencies with relatively complicated logics, normally we can use expressions to set it as shown below:

    1.png

    You will learn
    • Preset Expressions

    • cronExpression

    II. Preset Expressions

    Frequency expressions are written in cronExpression. You can enter custom cronExpression in the textbox, or click on the View Preset Expressions button to expand a list from which you can choose an expression.

    Click the button and select one of the text descriptions to insert its cronExpression into the above textbox. Click again to collapse the list. As shown below:

    2.gif

    The Preset Expressions are:

    • 19:50 on the last day of each month: 0 50 19 L * ?

    • 19:50 on the last working day of each month: 0 50 19 LW * ?

    • 19:50 on the fourth Friday of each month: 0 50 19 ? * 6#4

    • 19:50 every day in the fourth quarter of 2018: 0 50 19 * 10-12 ? 2018

    • 9 a.m. and 6 p.m. on each working day: 0 0 9,18 ? * MON-FRI

    III. cronExpression

    A Cron-Expression is a space-separated string of 6 to 7 fields (a field consists of fixed values and characters of specific meanings). There are 6 mandatory fields named "second", "minute", "hour of the day", "day of the month", "month", "day of the week" (the order of these fields are fixed from left to right ) and an optional field "year". Please check below for details.

    Field NameValues AllowedSpecial Chars Allowed 

      second

    0-59  

    , - * /  

      minute

    0-59  

    , - * / 

      hour of the day

    0-23  

    , - * /   

      day of the month

    1-31  

    , - * ? /  L W  

      month

    1-12 or JAN-DEC  

    , - * /  

      day of the week

    1-7 or SUN-SAT  

    , - * ? /  L #

      year (optional)

    empty, 1970-2099  

    , - * /  

    • '*' can be used in all the fields; it means [every]. For example, in the field "minute", '*' stands for "every minute".

    • '?' can be used in "day of the month" and "day of the week"; it means [unspecified value]. For example, '?' must be used in field "day of the month" if you need to specify "Wednesday", because which date of Wednesday remains unknown.

    • '-' can be used in all the fields; it means [a range of values]. For example, "10-12" in field "hour of the day" refers to "10 AM to 12 AM".

    • ',' can be used in all the fields; it means [specifying multiple values]. For example, "MON,WED,FRI" in field "day of the week" refers to "Monday, Wednesday and Friday".

    • '/' can be used in all the fields; it means "the increment of values". For example, "0/15" in field "second" refers to an arithmetic sequence of "second 0, 15, 30 and 45" which has a 15 seconds increment and max value of 60.

      • Adding a '*' before '/' means to start at second 0;

      • Each field has a series of start and end values, which cannot be greater than the maximum allowed value.

    • 'L' can be used in "day of the month" and "day of the week"; it means "Last". For example, "L" in field "day of the month" refers to "the last day of the month", in the field "day of the month" refers to "7" or "SAT"

      • When used in field "day of the week" following a certain number, take "6L" as an example, it means "the last Friday of the month" (Note: "1" refers to Sunday, so "6" means Friday).

    • 'W' can be used in field "day of the month"; it means "the nearest working day from a given date (Monday to Friday)". For example, if the "day of the month" field is set to "15W", it means "the nearest working day from 15th of this month". So, if the date of 15th is a Saturday, the task will be triggered on the 14th Friday; If it's a Sunday, then the task will be triggered on the 16th Monday; If Tuesday, triggered on the 15th.

      • If the field "day of the month" is set to "1W" and the 1st day of the month is a Saturday, the task will be triggered on next Monday (3rd), because it can't go beyond the range of one month, even though the day before (Friday) is a working day.

      • 'W' can only be used when field "day of the month" is of single value, rather than a series of values.

    • 'L' and 'W' can be used in "day of the month" at the same time: "LW"; it means "the last working day of the month".

    • '#' can be used in field "day of the week". For example, "6#3" refers to "the 3rd Friday of the month" ("6" means "Friday" and "#3" means "the 3rd one of the month"). Be aware that if you specified "1#5" but there isn't a 5th Sunday in the month, then the task won't be triggered that month.

    Note: for field "month" and"day of the week", the legitimate characters are NOT case-sensitive.

    You can find some examples below:

    Expressions
    Meanings  

    0 0 12 * * ?

    Triggered everyday at 12:00 noon

    0 15 10 ? * *

    Triggered everyday at 10:15 AM

    0 15 10 * * ?

    Triggered everyday at 10:15 AM

    0 15 10 * * ? *

    Triggered everyday at 10:15 AM

    0 15 10 * * ? 2005

    Triggered everyday at 10:15 AM in 2005

    0 * 14 * * ?

    Triggered every minute between 2:00 PM to 2:59 PM every day

    0 0/5 14 * * ?

    Triggered every 5 minutes between 2:00 PM to 2:55 PM every day

    0 55/10 14,18 * * ?

    Triggered everyday at 2:55 PM and 6:55 PM

    0 10,44 14 ? 3 WED

    Triggered every Wednesday at 2:10 PM and 2:44 PM in March

    0 15 10 ? * MON-FRI

    Triggered every Monday, Tuesday, Wednesday, Thursday, Friday at 10:15 AM

    0 15 10 15 * ?

    Triggered every 15th at 10:15 AM

    0 15 10 L * ?

    Triggered every last day of the month at 10:15 AM

    0 15 10 ? * 6L

    Triggered every last Friday of the month at 10:15 AM

    0 15 10 ? * 6L 2002-2005

    Triggered every last Friday of the month at 10:15 AM from 2002 to 2005

    0 15 10 ? * 6#3

    Triggered every 3rd Friday of the month at 10:15 AM

    0 0 0 L-2 * ? *

    Triggered every last but one day of the month (Supported in FineReport 10.0, not available for FineReport 9.0)

     

     

     


    Attachment List


    Theme: Decision-making Platform
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy