Search code examples
windowsamazon-ec2shutdown

EC2 windows instance as dev machine, need to auto-shutdown after X period of user inactivity


I want to use an EC2 windows instance as an development environment, and want it to shutdown automatically when there is X period of user inactivity (either no remote desktop connection or idle RD connection), so as to minimize costs. Any way to do this?


Solution

  • You can use task scheduler inside of the windows machine to set up a trigger that will shut down the machine when it is inactive.

    1. open the task scheduler (assuming windows 7 or 8 just type it in to search for it in the start/search box)

    2. on the right actions box create a task

    3. give it a name

    4. Run whether user is logged on or not

    5. Run with highest privileges (shutdown requires admin rights)

    6. Click Triggers tab

    7. New...

    8. Begin the task: set to on idle

    9. click ok

    10. click conditions tab

    11. Check mark start the task only if the computer is idle for (your amount of idle time)

    12. check restart if the idle state resumes

    13. Click the Actions Tab

    14. New...

    15. program = cmd.exe

    16. add arguments = shutdown /s /f

    Should be good to go after that