Amazon – Fazendo as máquinas do EC2 dormirem

Primeiro instale a linha de commando: Linha de Comando

Ligando às 19h:
0 19 * * * ~/start_instances.sh.

# start_instances.sh
 
export AWS_ACCESS_KEY="UTHEENDZNAPPA20HAI11"
export AWS_SECRET_KEY="eij5ugaiphee6uusheg6eiVaiD0ein8moh7ieS0o"
 
aws ec2 start-instances i-912345ab i-812345bc

Desligando às 7h:
0 7 * * * ~/stop_instances.sh.

# stop_instances.sh
 
export AWS_ACCESS_KEY="UTHEENDZNAPPA20HAI11"
export AWS_SECRET_KEY="eij5ugaiphee6uusheg6eiVaiD0ein8moh7ieS0o"
 
aws ec2 stop-instances i-912345ab i-812345bc

Exemplo de CRONTAB:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
0 7 * * * ~/stop_instances.sh
0 19 * * * ~/start_instances.sh

Referência