Scheduling Amazon ECS Cluster
Can ZopNight schedule Amazon ECS Cluster?
Cluster-level scheduling walks every ECS service and sets each desired count to 0, restoring the saved numbers at start. On Fargate that ends task billing outright; on the EC2 launch type the container instances keep running and billing, so the schedule must be paired with scaling the instance fleet.
How the stop works
| Field | Value |
|---|---|
| Behaviour | every service in the cluster is scaled to a desired count of zero on stop and restored on start. |
Example schedules
- 0 8 * * 1-5 — Business Hours Start: Start at 8:00 AM on weekdays
- 0 18 * * 1-5 — Business Hours Stop: Stop at 6:00 PM on weekdays
- 0 22 * * * — Night Shutdown: Stop at 10:00 PM every day
- 0 6 * * 1-5 — Morning Startup: Start at 6:00 AM on weekdays
- 0 20 * * 5 — Weekend Shutdown: Stop at 8:00 PM on Friday
- 0 7 * * 1 — Weekend Startup: Start at 7:00 AM on Monday
A fan-out, not a switch
ECS has no operation that stops a cluster. What the schedule actually does is enumerate the services in the cluster and drive each one’s desired count to zero, remembering the previous number per service. The start run replays those saved counts. Twenty services means twenty updates each way, applied in one scheduled action instead of twenty separate schedules.
Launch type decides whether money moves
On Fargate, tasks are the unit of billing, so zero tasks is zero compute spend. The fan-out is the entire saving. On the EC2 launch type the tasks stop but the container instances underneath keep running and keep billing. Emptying the services without shrinking the instance fleet saves nothing; pair the schedule with a capacity provider whose managed scaling can release instances, or schedule the underlying Auto Scaling group as well.
What the sweep cannot reach
Two kinds of workload sit outside the service list. Standalone tasks started with run-task (one-off jobs, scheduled EventBridge tasks) have no desired count and keep running or keep launching on their own timers. And services using the daemon strategy place one task per instance rather than tracking a count, so they empty only when the instances themselves go away.
Per-service restore and its edge
Each service comes back to the count captured at its own stop time. A service that was mid-scale-up at 6pm is restored to the number it happened to have at that moment, and the restore overwrites any change made while the cluster sat at zero, whether a rewritten task definition or an edited count in the console. Deploy pipelines that run overnight should be aware the morning restore wins.
Draining takes minutes, not seconds
Every service drains through its load balancer’s deregistration delay, 300 seconds by default. A cluster-wide stop is finished when the slowest service finishes, so the true off window starts several minutes after the cron fires.