For business with clear peak and off-peak periods, such as enterprise office automation (OA) systems and Customer Relationship Management (CRM) systems, keeping Elastic Compute Service (ECS) instances running during off-peak hours (such as nights or weekends) wastes resources. You can use the economical mode of ECS and the scheduled startup and shutdown feature of CloudOps Orchestration Service (OOS) to automate management, reduce costs, and improve O&M efficiency.
Background information
If you stop an ECS instance in economical mode, the following instance resources are recycled and no longer billed:
vCPUs (and GPUs or FPGAs for a heterogeneous computing instance)
Memory
Static public IP addresses (public IP addresses automatically assigned to the instance)
Image licenses
However, other instance resources, such as cloud disks, elastic IP addresses (EIPs), and snapshots, are retained and continue to be billed. For more information, see Economical mode.
Prerequisites
The ECS instances that you want to manage are pay-as-you-go or spot instances.
Procedure
1. Add tags to instances
Add tags to ECS instances that require scheduled startup and shutdown. This allows you to select instances based on the tags in CloudOps Orchestration Service tasks. For example, add the machine:StopAndStart tag to ECS instances that require daily scheduled startup and shutdown. For more information, see Tags.
2. Configure services to automatically start on instance startup
To ensure that internal services run as expected, configure them to automatically start on instance startup.
Linux instance
In this example, systemd is used on a Linux instance to configure a service named myapp to automatically start on instance startup.
Create a file named
myapp.service
in the/etc/systemd/system
directory and add the following content to the file:# System unit configuration [Unit] # Service description Description=My Application Service # Service configuration [Service] # Startup script path. Customize the startup script based on the service. ExecStart=/path/to/myapp/start.sh # Always restart the service Restart=always # Installation configuration [Install] # Configure the startup target. WantedBy=multi-user.target
Run the following commands to enable the service to automatically start on instance startup and start the service:
#Enable automatic startup sudo systemctl enable myapp.service #Start the service sudo systemctl start myapp.service
Windows instance
In this example, Task Scheduler is used on an instance that runs Windows Server 2025 to configure a program to automatically start on instance startup.
Search for Task Scheduler in the Start menu and open it.
In the top navigation bar, choose Action > Create Basic Task.
Enter a task name and click Next.
On the Task Trigger page, select When the computer starts and click Next.
On the Action page, select Start a program and click Next.
Upload a program or script, click Next, and then click Finish to save the task.
3. Create a scheduled startup and shutdown task
Go to CloudOps Orchestration Service - Scheduled Startup and Shutdown.
In the top navigation bar, select the region and resource group of the resource that you want to manage.
Click Create. In the Select Task Type section, configure the parameters, such as Task Name, Execution Cycle, Task Type, Time Zone, Shutdown Time, Startup Time, and End Time.
For example, you can set Startup Time to 08:00:00 and Shutdown Time to 21:00:00 to start specific ECS instances at 08:00:00 and stop them at 21:00:00 daily. After you configure the preceding parameters, you can view the scheduled times in the Execution Time Preview section.
Configure Resource Type, Stop Mode, Hibernate Instance, and Permissions.
Resource Type: Select ECS Instance.
Stop Mode: Select Economical Stop Mode.
NoteYou can stop pay-as-you-go ECS instances in economical mode to retain instance data and configurations while reducing costs. After you stop the instances in economical mode, you are no longer charged for their computing resources (vCPUs and memory), static public IP addresses, and image licenses. However, you are still charged for other instance resources, such as system disks, data disks, EIPs, and snapshots. For more information, see Economical mode.
Hibernate Instance: Do not turn on this switch.
Permissions: Select Default Service-linked Role.
Click Select Instances, select Specify Instance Tags, configure Select a region, and then select an existing tag, such as machine:StopAndStart.
Click Advanced (Optional), set Rate control type to Concurrency-based Control, and then configure Concurrency and Error Threshold.
In the Execution Settings(Optional) section, retain the default values of the parameters and click Create.
In the Parameter Confirmation dialog box, verify that the configurations are correct and click OK.
View the execution details.
On the Scheduled Startup/Shutdown page, find the scheduled startup and shutdown task you created and click Details in the Actions column to view the execution details of the task.
References
CloudOps Orchestration Service is a comprehensive, automated O&M service provided by Alibaba Cloud free of charge to help you manage and execute O&M tasks in the cloud. You can use OOS to run repetitive, event-driven, scheduled, and cross-region O&M tasks, batch handle O&M tasks, and manage approval requests. OOS also serves as an O&M task standardization platform that allows you to create templates from O&M, operation, and maintenance manuals based on best practices for Operations as Code. For more information, see What is OOS?