Snooze to Save Money

Posted on Mon 18 May 2020 in bash • Tagged with aws, bash, beginnersLeave a comment

Cloud instances bill by the hour (or the minute) – and right now you're burning money. Use snooze to auto-shutdown your instances in 45 minutes.

Add snooze to your ~/.bashrc

alias snooze='sudo shutdown -c ;  sudo shutdown -h +45 &'
snooze

When you want to extend your session, run snooze

Broadcast message from ec2-user@ip-172-31-43-250
    (/dev/pts/1) at 2:50 ...

The system is going down for halt in 45 minutes!

How does this work?

shutdown -c cancels the shutdown, and shutdown -h +45 schedules a shutdown in 45min.

How can we automate this?

Stay tuned !

Continue reading