Creating a Scheduled Task
What Is a Scheduled Task?
In many cases, some processing does not require manual intervention. Such processing can be completed by job schedules at the backend. For example, a scheduled task in the system suspends expired offerings at 03:00 every day. Astro Zero allows you to create, view, and delete scheduled tasks and monitor task execution results.
In addition to creating scheduled tasks during application development, you can also create scheduled tasks in environment configuration. For details, see Managing Scheduled Tasks in Applications. The difference is that scheduled tasks created in the application designer can be packaged and released together with applications. Scheduled tasks created in the environment configuration cannot be released with applications.
Creating a Scheduled Task
- Log in to the application designer by referring to Logging In to the Application Designer.
- In the navigation pane, choose BPMs.
- (Optional) Click
next to Scheduled Task to add a folder.
By default, scheduled tasks are stored in the root folder. Before creating a scheduled task, you need to create a folder for storing the scheduled task. You can drag the scheduled task to a specified folder.
- Move the cursor to the created scheduled task folder and click
. The page for creating a scheduled task is displayed.
If the scheduled task folder has not been created, click
next to the scheduled task. The page for creating a scheduled task is displayed.
- Configure the scheduled task and click Save.
Let's assume that you need to create a scheduled task OfferingOffline to remove expired products at 00:00 every day from November 25, 2021. This function is realized using the OfferingOffline script. Before creating a scheduled task, develop and enable a script for implementing the schedule. For details, see Scripts.
Figure 1 Configuring a scheduled taskTable 1 Scheduled task parameters Parameter
Description
Name
Enter the name of the scheduled task. The naming requirements are as follows:
- The value cannot exceed 64 characters, including the prefix namespace.
To prevent duplicate data names among different tenants, each tenant must define a unique namespace when first creating an application. A tenant can create only one namespace. After being created, the namespace cannot be modified.
- Start with a letter and can contain letters, digits, and underscores (_). It cannot end with an underscore (_).
Example: OfferingOffline.
Type
Type of the scheduled task. Scripts and flows are supported.
- Script: Use a script to develop scheduled tasks.
- Flow: Use a flow to develop and implement the scheduled task.
Example: Script.
Script/Flow
Ensure that the script or flow has been enabled. Otherwise, the script or flow cannot be selected. For details about how to enable a script or flow, see Creating a Blank Script and Creating a Blank Flow.
Example: OfferingOffline.
First Execution Time
Time when the scheduled task is executed for the first time.
Example: 2021-11-25 00:00:00.
Execute Count
Number of times that the scheduled task is executed.
- Once: The task is executed either immediately or at a specified time, but only once.
- Multiple times (based on frequency): The task is executed periodically at the specified interval, starting from the specified time.
- By Cron Expression: The task is executed based on the configured Cron expression.
Example: Multiple times (based on frequency)
By Cron Expression
If Execute Count is set to By Cron Expression, you need to set the expression of the scheduled task.
A Cron expression is a time-based syntax used to specify the execution time, frequency, and interval of a scheduled task. A Cron expression consists of six fields: second, minute, hour, date, month, and day of the week. For details on the values for each field, see Table 2.
Example:
Description Expression Execute at 6:00 every day 0 0 6 * * ? Execute at 0:00, 6:00, and 12:00 daily 0 0 0,6,12 * * ? Execute at 2:00 every Saturday 0 0 2 ? * SAT Trigger at 10:20 AM from Monday to Friday 0 20 10 ? * MON-FRI
Execute Frequency
If Execute Count is set to Multiple times (based on frequency), you need to set the execution frequency of the scheduled task.
Example: 1.
Execution Cycle Unit
Time unit for executing the task. This parameter is available only when Execute Count is set to Multiple times (based on frequency).
Example: Day.
Description
Enter the description of the scheduled task.
Value: 1–255 characters.
Table 2 Cron expression field values Field
Allowed Value
Allowed Special Character
Second
0–59
Not supported
Minute
0–59
* /
Hour
0–23
- * /
Date
1–31
- * ? /
Month
1–12
JAN-DEC - * /
Day of Week
1–7
SUN-SAT - * ? /
Table 3 Supported special characters in a cron expression Character
Description
Example
,
Used to specify additional values.
1,3,4,7,8.
*
Used to select all values within a field.
If the Minute field is set to *, an event is triggered every minute.
?
Used to match any value of a field. However, it can be used only in the Date and Day of week fields because the two fields affect each other.
To trigger a scheduled task on the 20th day of each month, regardless of the day of week, use the following format: 13 13 15 20 *?
The 20th day is specified in the Date field, the last character of the Day of week field can only be a question mark (?) instead of an asterisk (*). If the last character is *, it indicates that the event is triggered on any day of a week, which is exclusive with the 20th day of the date field. In this case, the expression is incorrect.
-
Used to specify ranges.
For the Hour field, the value ranges from 8 to 10, indicating that the incident is triggered every hour from 8:00 to 10:00.
/
Used to specify increments. An incident is triggered from the specified time and at a fixed interval.
In the Hour field, */3 is equivalent to "every three hours". That is, an incident is triggered at the following time points in a day: 0, 3, 6, 9, 12, 15, 18, and 21.
- The value cannot exceed 64 characters, including the prefix namespace.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot