用于需要定时的运维场景。启动执行后,OOS即将执行置于等待状态,直到指定的时刻才开始后续的任务。任务完成以后重新进入到等待状态。 触发器有如下限制: 流程图说明如下: 示例 cron类型 at类型用途
限制
语法
Tasks:
- Name: timerTask # 任务名称
Action: ACS::TimerTrigger
Properties:
Type: cron # 必填,时间类型,可选cron、at或rate。
Expression: '0 * * ? * *' # 必填,cron表达式(cron默认是按UTC时间计算)、日期时间表达式或rate。
TimeZone: 'Asia/Shanghai' # 选填,所选时间对应的时区,默认为UTC。
EndDate: '2020-12-29T09:19:30Z' # 必填,终止时间(UTC时间,格式为YYYY-MM-DD或YYYY-MM-DDThh:mm:ssZ)。
{
"Tasks": [
{
"Name": "timerTask",
"Action": "ACS::TimerTrigger",
"Properties": {
"Type": "cron",
"Expression": "0 * * ? * *",
"EndDate": "2020-12-29T09:19:30Z",
"TimeZone": "Asia/Shanghai"
}
}
]
}
流程图
---
FormatVersion: OOS-2019-06-01
Description: Schedule to reboot ECS instances.
Tasks:
- Name: timer
Action: ACS::TimerTrigger
Properties:
Type: cron
Expression: 5 minute
EndDate: 2020-12-20T00:00:00Z
- Name: rebootInstance
Action: ACS::ECS::RebootInstance
Properties:
InstanceId: "i-xxxxx"
{
"FormatVersion": "OOS-2019-06-01",
"Description": "Schedule to reboot ECS instances.",
"Tasks": [
{
"Name": "timer",
"Action": "ACS::TimerTrigger",
"Properties": {
"Type": "cron",
"Expression": "5 minute",
"EndDate": "2020-12-20 00:00:00 UTC"
}
},
{
"Name": "rebootInstance",
"Action": "ACS::ECS::RebootInstance",
"Properties": {
"InstanceId": "i-xxxxx"
}
}
]
}
---
FormatVersion: OOS-2019-06-01
Description: Schedule to reboot ECS instances.
Tasks:
- Name: timer
Action: ACS::TimerTrigger
Properties:
Type: at
Expression: '2020-02-29T09:17:35Z'
EndDate: 2020-12-20T00:00:00Z
- Name: rebootInstance
Action: ACS::ECS::RebootInstance
Properties:
InstanceId: "i-xxxxx"
{
"FormatVersion": "OOS-2019-06-01",
"Description": "Schedule to reboot ECS instances.",
"Tasks": [
{
"Name": "timer",
"Action": "ACS::TimerTrigger",
"Properties": {
"Type": "at",
"Expression": "2020-02-29T09:17:35Z",
"EndDate": "2020-12-20T00:00:00.000Z"
}
},
{
"Name": "rebootInstance",
"Action": "ACS::ECS::RebootInstance",
"Properties": {
"InstanceId": "i-xxxxx"
}
}
]
}