CloudFlow allows you to configure cron expressions to schedule workflows on a regular basis or at a specified time. This topic describes how to configure time-based scheduling in CloudFlow.
Prerequisites
EventBridge
EventBridge is activated and the required permissions are granted to a Resource Access Management (RAM) user. For more information, see Activate EventBridge and grant permissions to a RAM user.
CloudFlow
A workflow is created. For more information, see Create a workflow.
Precautions
If the number of existing custom buses and the number of existing event rules reach the upper limits, you can no longer create time-based scheduling. For information about the limits on the number of resources that are used to create workflow scheduling in a single Alibaba Cloud account and a single region, see Limits.
Configure time-based workflow scheduling in the CloudFlow console
Log on to the CloudFlow console. In the top navigation bar, select a region.
On the Workflows page, click the workflow for which you want to configure time-based scheduling.
On the Workflow Details page, click the Workflow Scheduling tab and click Create Workflow Scheduling.
In the Create Workflow Scheduling panel, select Scheduled Trigger from the Scheduling Type drop-down list, configure parameters, and then click OK. The following table describes the parameters.
Parameter
Description
Example
Name
Enter a name for the time-based scheduling.
schedule-test
Description
Enter a description for the time-based scheduling.
test schedule
Trigger Cycle
Select a mode for configuring scheduling time and specify the time rule.
Fixed Cycle: the interval at which the workflow is scheduled.
Custom Cron: a cron expression that defines the scheduling time. For more information about the description and examples of cron expressions, see Parameters about scheduling time.
Select Fixed Cycle for the Trigger Cycle parameter and set the Cycle Type parameter to Second and the Cycle parameter to 30. The workflow is scheduled every 30 seconds.
Trigger Message
Enter a custom parameter. The value of this parameter is a JSON string.
{"key": "value"}
NoteThe first time you create workflow scheduling, you must attach the AliyunEventBridgeFullAccess policy to the CloudFlow scheduling role and activate the EventBridge service.
After the workflow scheduling is created, you can follow the on-screen instructions to view, edit, delete, enable, or disable the workflow on the Workflow Scheduling tab of the workflow details page.
Parameters about scheduling time
The parameters of time-based scheduling are in the following format:
{
UserData: "payload"
Schedule: "cronExpression"
TimeZone: "GMT+0:00"
}UserData: the input of the time-based scheduling, which is in the format of a JSON object.
TimeZone: the time zone based on which the time-based scheduling is executed. Default value: GMT+0:00 (UTC+0). The time zone of UTC+8 is GMT+8:00.
Schedule: the time when the workflow is to be scheduled. The value can be a cron expression.
The following table describes common examples of the Schedule parameter. For example, if you want a workflow to be scheduled at 12:00 UTC+8, you can set the Schedule parameter to the
0 0 12 * * ?expression and the time zone toGMT+8:00.Example
Cron expression
Time zone
Schedule the workflow at 12:00 every day.
0 0 12 * * ?
GMT+8:00
Schedule the workflow at 12:30 every day.
0 30 12 * * ?
GMT+8:00
Schedule the workflow at the 26th, 29th, and 33rd minutes every hour.
0 26,29,33 * * * ?
GMT+8:00
Schedule the workflow at 12:30 every day from Monday to Friday.
0 30 12 ? * MON-FRI
GMT+8:00
Schedule the workflow every 5 minutes from 12:00 to 14:00 every day from Monday to Friday.
0 0/5 12-14 ? * MON-FRI
GMT+8:00
Schedule the workflow at 12:00 every day from January to April.
0 0 12 ? JAN,FEB,MAR,APR *
GMT+8:00
Trigger the workflow at 14:10 and 14:44 on each Wednesday of March on an annual basis.
0 10,44 14 ? 3 WED
GMT+8:00
Trigger the workflow at 23:00 on the last day of each month.
0 0 23 L * ?
GMT+8:00
Trigger the workflow at 10:15 on the last Friday of each month.
0 15 10 ? * 6L
GMT+8:00
Trigger the workflow at 10:15 on the third Friday of each month.
0 15 10 ? * 6#3
GMT+8:00
Field description
Field
Valid values
Allowed special characters
Seconds
0 to 59
, - * /
Minutes
0 to 59
, - * /
Hours
0 to 23
, - * /
Day-of-month
1 to 31
, - * ? / L W
Month
1 to 12 or JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
, - * /
Day-of-week
1, 2, 3, 4, 5, 6, 7, or SUN, MON, TUE, WED, THU, FRI, SAT
, - * ? / L #
Special characters
Character
Description
Example
*
Specifies any or each.
In the Minutes field, 0 specifies that the workflow is executed at the 0th second of every minute.
,
Specifies a value list.
In the Day-of-week field, MON specifies Monday, WED specifies Wednesday, and FRI specifies Friday.
-
Specifies a range.
In the Hours field, 10-12 specifies a time range from 10:00 to 12:00 in UTC.
?
Specifies an uncertain value.
This character is used together with other specified values. For example, if you specify a specific date but you do not care what day of the week it is, you can use this special character in the Day-of-week field.
/
Specifies increments. n/m indicates an increment of m starting from the position of n.
In the minute field, 3/5 specifies that the workflow is executed every 5 minutes starting from the 3rd minute.
L
Specifies the last day or Saturday of the month. 6L that is used in the Day-of-week field specifies the last Friday of the month.
This character that is used in the Day-of-month field specifies the last day of the month. 6L that is used in the Day-of-week field specifies the last Friday of the month.
W
Is used in the Day-of-week field to specify the nearest business day from Monday to Friday.
1W that is used in the Day-of-month field specifies that the workflow is executed on the first business day of each month.
#
Is used in the Day-of-week field to specify a day of the week and a week of the month.
6#3 specifies the third Friday of each month.
Input format
Time-based scheduling schedules your workflow based on the following input format. The push format complies with the CloudEvents specification.
{
"datacontenttype":"application/json;charset=utf-8",
"aliyunaccountid":"143998900779****",
"aliyunpublishtime":"2022-09-21T05:00:00.035Z",
"data":{
"TimeZone":"GMT+0:00",
"Schedule":"0/30 * * * * ?",
"UserData":{
"key":"value"
}
},
"specversion":"1.0",
"aliyuneventbusname":"Housekeeping-Bus",
"id":"d100262d-90c7-4caf-a3b5-813f3526a1f7-****",
"source":"housekeeping.scheduledevent",
"time":"2022-09-21T05:00:00Z",
"aliyunregionid":"cn-beijing",
"type":"eventbridge:Events:ScheduledEvent"
}{
"datacontenttype":"application/json;charset=utf-8",
"aliyunaccountid":"143998900779****",
"aliyunpublishtime":"2022-09-21T05:00:00.035Z",
"data":{
"TimeZone":"GMT+0:00",
"Schedule":"0/30 * * * * ?",
"UserData":{
"key":"value"
}
},
"specversion":"1.0",
"aliyuneventbusname":"Housekeeping-Bus",
"id":"d100262d-90c7-4caf-a3b5-813f3526a1f7-****",
"source":"housekeeping.scheduledevent",
"time":"2022-09-21T05:00:00Z",
"aliyunregionid":"cn-beijing",
"type":"eventbridge:Events:ScheduledEvent"
}UserData: the input that you specify in the scheduling settings. The value can be read from $Input.data.UserData in a flow definition. For more information, see Inputs and outputs.
TimeZone: the time zone based on which the time-based scheduling is executed. Default value: GMT+0:00 (UTC+0). The time zone of UTC+8 is GMT+8:00.
Schedule: the time when the workflow is to be scheduled. The value can be a cron expression.