Create a scheduled start and stop rule

更新时间:
复制 MD 格式

To save costs, you can create a scheduled start and stop rule for your applications. Stopped applications do not incur computing resource fees.

1. Grant full SAE permissions to OOS

The scheduled start and stop feature uses CloudOps Orchestration Service (OOS). You must first create an OOSServiceRole RAM role and grant it the AliyunSAEFullAccess policy, which provides full permissions to manage SAE.

  1. Log on to the RAM console as a RAM administrator.

  2. In the left-side navigation pane, choose Identities > Roles.

  3. On the Roles page, click Create Role.

    image

  4. On the Create Role page, set Principal Type to AnyTunnel. In the Principal Name field, search for OOS, select CloudOps Orchestration Service, and then click OK.

  5. In the dialog box that appears, enter OOSServiceRole as the Role Name. On the Permissions tab, click Grant Permission, search for and select the AliyunSAEFullAccess policy in the Policies area, and then click OK.

2. Manage scheduled start and stop rules

  1. Navigate to the SAE Namespaces page. In the top navigation bar, select the target region. Click the name of the target namespace to go to its details page.

  2. In the left-side navigation pane, click Scheduled Start and Stop Rules. On the Scheduled Start and Stop Rules page, click Create Scheduled Start and Stop Rule.

  3. In the Create Scheduled Start and Stop Rule panel, configure the parameters and click OK.

    Parameter

    Description

    Rule Name

    A custom name for the scheduled start and stop rule.

    Trigger

    • Batch Start Applications: Starts the selected applications in the namespace.

    • Batch Stop Applications: Stops the selected applications in the namespace.

    Frequency

    • Only Once: Runs once at the specified time.

    • Scheduled: Runs on a recurring schedule defined by a cron expression. The valid values for each field are:

      • Minute: [0, 59].

      • Hour: [0, 23], where 0 indicates midnight (00:00).

      • Day of month: [1, 31].

      • Month: [1, 12] or [JAN, DEC]. This field cannot be modified.

      • Day of week: [1, 7] or [Sun, Sat]. 1 represents Sunday, and 7 represents Saturday. For example, to trigger the rule on Tuesday, Thursday, and Saturday, enter 3,5,7 or Tue,Thu,Sat.

      Note

      The notation [1, 7] indicates a value range. If you enter 1,7 in the day-of-week field, the rule triggers only on Sunday and Saturday.

    Pre-execution Notification Configuration

    Provide a webhook URL for a DingTalk chatbot. SAE sends a notification to this URL before each scheduled task runs, to notify you of system operations. The custom keyword for the DingTalk chatbot must be set to SAE. For more information, see Obtain the webhook URL of a DingTalk chatbot.

    Triggered Applications

    • Start/Stop All Applications: Starts or stops all applications in the target namespace. Before each task execution, SAE automatically scans for the latest list of applications and then performs the start or stop operation.

    • Start/Stop Some Applications: After you select Start/Stop Some Applications, select the application type that you want to start or stop from the drop-down list, and then select the checkboxes next to the target applications.

    After the rule is created, you can view it on the Scheduled Start and Stop Rules page. You can also Disable, Edit, or Delete existing rules.

Cron expressions

A cron expression lets you define more flexible schedules, trigger times, and recurrence patterns. The following table shows some examples.

Description

Field values

Cron expression

At 22:30 from Monday to Friday

Minute: 30, Hour: 22, Day of month: ?, Month: *, Day of week: 2,3,4,5,6

30 22 ? * 2,3,4,5,6

At 00:00 on the 5th, 15th, and 25th of every month

Minute: 0, Hour: 0, Day of month: 5,15,25, Month: *, Day of week: ?

0 0 5,15,25 * ?

When you write a cron expression, follow these rules:

  • You can specify the start and stop trigger time by either day of the month or day of the week. If you specify a value for one, the other must be set to the wildcard character ?, which indicates no restriction. For example, if you specify the 1st and 2nd of the month, the day of the week must be set to ?.

  • Use only half-width characters in the cron expression, such as the asterisk (*) and question mark (?) wildcards.

  • Use a comma (,) to separate multiple values in a field.

  • A hyphen (-) specifies a range of values. For example, entering 1-5 for the day indicates the 1st to the 5th day.

  • For the day-of-week field, 1 represents Sunday, 2 represents Monday, and so on, up to 7 for Saturday. For example, the range for Monday to Friday is 2-6.