Expression Setting for Task Schedule Execution Frequency

  • Last update:April 26, 2023
  •  Overview

    Task schedule means an event or task triggered at a fixed time. Obviously, when setting a scheduled task, it is important to set the execution time. However, a task may be executed every day, every other day, or only once, etc. Through different expressions, you can set different combinations of execution frequency. As is shown below: 

    Scheduled Expression

    Expression Setting is a new mechanism set by Cron Expression. You can fill in the text box with Cron Expression manually, or directly click the View Preset Expressions to set scheduled tasks. When clicking View Preset Expessions, the preset expressions list will expand. When clicking a text in the list, the corresponding Cron Expression will be displayed and saved in the text box. Click Retract Preset Expressions and you can collapse the list of preset expressions. As is shown below: 

    There are several preset expressions:

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

    • b. 19:50 on the last working day of each month (Monday to Friday): 0 50 19 LW * ?

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

    • d. 19:50 a.m. each day in the fourth quarter of 2018:0 50 19 *      10-12 ? 2018 2018

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

    Cron Expression

    A Cron Expression is a string separated by 5 or 6 spaces, and divided into 6 or 7 domains, each of which representing a time range.

    There are two syntax formats for Cron Expression:

    • Seconds Minutes Hours DayofMonth Month DayofWeek Year

    • Seconds Minutes Hours DayofMonth Month DayofWeek

    Notes:

    1.     DayofMonth means the day in the month;

    2.     DayofWeek means the day in the week;

    3.     Year is optional.

    Domain

    The characters that may appear in each domain are as follows:

    Domains
    Allowed ValuesAllowed Special Characters

    Seconds

    Integers from 0 to 59

    Four characters: , - * /

    Minutes

    Integers from 0 to 59

    Four characters: , - * /

    Hours

    Integers from 0 to 23

    Four characters: , - * /

    DayofMonth

    Integers from 0 to 31 (considering the number of   days in the month)

    Eight characters: ,- * ? / L W C

    Month

    Integers from 1 to 12 or months from JAN to DEC

    Four characters: , - * /

    DayofWeek

    Integers from 1 to 7 or days from SUN to SAT (1=SUN,   2=MON and as follows)

    Eight characters: , - * ? / L C #

    Year

    From 1970 to 2099

    Four characters: , - * /

    Each domain may contain special characters in addition to numbers. The meanings of these special characters are as follows:

    CharactersMeanings

    *

    Indicates any value that matches the domain. For example, using * in the Minutes domain mea--ns the event will be triggered every minute.

    ?

    Used only in the DayofMonth and DayofWeek domains. Although it also matches any value in other domain, actually it works only in   the two domains. Because DayofMonth domain and DayofWeek domain will affect each other. For example, if you want to trigger a scheduled task on the 20th day of every month, regardless of which day of the week it is, you can only use the expression: 13 13 15 20 * ?, where the last character can only be ?. Instead, if you use *, it will trigger the task every day the week.

    -

    Indicates a range, for example, using 5-20 in the Minutes domain means triggering once per minute from 5 to 20 minutes.

    /

    The number on the left indicates the start time of the trigger, and the number on the right indicates the interval time. For example, using 5/20 in the Minutes domain means triggering every 20 minutes, which will start at 5 minutes and also be triggered at 25 minutes, 45 minutes, etc.

    ,

    Indicates listing enumeration values. For example, using 5,20 in the Minutes domain means triggering only at 5 minutes and 20   minutes.

    L

    Used only in the DayofMonth and DayofWeek domains, which means the "last". However, it represents different meanings in the two domains. In the DayofMonth domain, it represents the last day of   the month, such as January 31st, or February 28th in non-leap years. While in the DayofWeek domain, it means Saturday, equivalent to 7. However, if there is a value in front of L, it has a different meaning. For example, 6L in the Month domain means the sixth-to-last day of the month; FRIL in the DayofWeek domain means the last Friday of the month.

    W

    Used only in the DayofMonth domain, and it modifies the leading date to indicate the closest working day (Monday to Friday) to that date. For example, 15W represents the nearest working day to the 15th of that month. If the 15th day of that month is Saturday, then it matches Friday the 14th; if the 15th day is Sunday, then it matches Monday the 16th; if the15th day is Tuesday, then the result is Tuesday the 15th. However, you cannot match the associated date to another month. For example, if you specify 1W and the 1st is Saturday, the matched result will be Monday the 3rd instead of the last day of the previous month. You can only use W to specify a single date, but not a date range.

    LW

    In the DayofMonth domain, L and W can be used in combination, which means the last working day (Monday to Friday) of the month.

    C

    Used only in the DayofMonth and DayofWeek domains, which means the date associated with the plan, representing the meaning of “calendar”. If the date is not associated, it is equivalent to all dates in the calendar. For example, 5C in the DayofMonth domain is equivalent to the first day after 5 days on the calendar; 1C in the week domain is equivalent to the first day after Sunday.

    #

    Used only in the DayofWeek domain to indicate a certain working day (Monday to Friday) of the month. For example, 6#3 represents the third Friday of the current month (6 represents Friday, #3   represents the third one); while 4#5 represents the fifth Wednesday of the current month. If there is no fifth Wednesday in the current month, it will be ignored and not triggered.

    Examples

    An example of a Cron Expression is shown below:

    Note: Check whether the expression is correct, and fill the correct expression into the text box after confirmation.

    Expressions
    Meanings

    */5 * * * * ?

    Execute once every 5 seconds

    0 */1 * * * ?

    Execute once every 1 minute

    0 0 */1 * * ?

    Execute once every hour

    0 0 12 * * ?

    Trigger every day at 12 p.m.

    0 0 0,13,18,21 * * ?

    Trigger every day once at 12 a.m., 1 p.m., 6 p.m., and 9 p.m.

    0 0 0-8 * * ? 

    Trigger every hour once from 12 a.m. to 8 a.m.

    0 15 10 ? * *

    Trigger every day at 10:15 a.m.

    0 15 10 * * ?

    Trigger every day at 10:15 a.m.

    0 15 10 * * ? *

    Trigger every day at 10:15 a.m.

    0 15 10 * * ? 2005

    Trigger every day at 10:15 a.m. in 2005

    0 * 14 * * ?

    Trigger every minute from 2 p.m. to 2:59 p.m. every   day

    0 0/5 14 * * ?

    Trigger every 5 minutes from 2 p.m. to 2:55 p.m.   every day

    0 55/10 14,18 * * ?

    Trigger every day at 2:55 p.m. and 6:55 p.m.

    0 10,44 14 ? 3 WED

    Trigger at 2:10 p.m. and 2:44 p.m. every Wednesday   in March

    0 15 10 ? * MON-FRI

    Trigger at 10:15 on each working day

    0 15 10 15 * ?

    Trigger at 10:15 on the 15th of every month

    0 15 10 L * ?

    Trigger at 10:15 on the last day of each month

    0 15 10 ? * 6L

    Trigger at 10:15 on the last Friday of every month

    0 15 10 ? * 6L 2002-2005

    Trigger at 10:15 on the last Friday of each month from 2002 to 2005

    0 15 10 ? * 6#3

    Trigger at 10:15 on the third Friday of each month

    0 0 0 L-2 * ? *

    The second to last day of each month (supported in FineReport 10.0, but not supported in 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