Sample schedule
The Instance Scheduler on AWS allows you to automatically start and stop Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Relational Database Service (Amazon RDS) instances. The following section shows how to configure the periods and schedule required to run instances Monday 9 am ET to Friday 5 pm ET. Since Monday and Friday are not full days, this schedule includes three periods to accommodate: Monday, Tuesday-Thursday, and Friday.
Periods
The first period starts tagged instances at 9 am Monday and stops at midnight. This period includes the following fields and values.
Field | Value |
---|---|
begintime |
09:00 |
endtime |
23:59 |
name |
mon-start-9am |
weekdays |
mon |
The second period runs tagged instances all day Tuesday through Thursday. This period includes the following fields and values.
Field | Value |
---|---|
name |
tue-thu-full-day |
weekdays |
tue-thu |
The third period stops tagged instances at 5 pm on Friday. This period includes the following fields and values.
Field | Value |
---|---|
begintime |
00:00 |
endtime |
16:59 |
name |
fri-stop-5pm |
weekdays |
fri |
Schedule
The schedule combines the three periods into the schedule for tagged instances. The schedule includes the following fields and values.
Field | Value |
---|---|
name |
mon-9am-fri-5pm |
periods |
mon-start-9am,tue-thu-full-day,fri-stop-5pm |
timezone |
America/New_York |
Instance tag
To apply this schedule to instances, you must add Schedule
as the tag key and mon-9am-fri-5pm
as
the tag value for the instances. You can run the following AWS CLI command:
aws ec2 create-tags --tags "Key=Schedule,Value=mon-9am-fri-5pm" --resources "
[INSTANCE_ID]
"
If you changed the default tag name in the AWS CloudFormation Instance Scheduler tag
name parameter, your tag key and value will be different. For example, if you
entered Sked
as your tag name, your tag key will be Sked
and the tag
value will be mon-9am-fri-5pm
. For more information, refer to Tag
your resources in the Amazon Elastic Compute Cloud User Guide.
Scheduler CLI
To configure the above schedule using the Instance Scheduler CLI, use the following commands:
scheduler-cli create-period --stack
<stackname>
--name mon-start-9am --weekdays mon --begintime 9:00 --endtime 23:59 scheduler-cli create-period --stack<stackname>
--name tue-thu-full-day --weekdays tue-thu scheduler-cli create-period --stack<stackname>
--name fri-stop-5pm --weekdays fri --begintime 0:00 --endtime 17:00 scheduler-cli create-schedule --stack<stackname>
--name mon-9am-fri-5pm --periods mon-start-9am,tue-thu-full-day,fri-stop-5pm --timezone America/New_York