Skip to content

Instantly share code, notes, and snippets.

@why-not
why-not / stop-idle-azure.py
Last active Jul 21, 2021
Automatically Shutting Down and Deallocating an AZURE VM (when idle AND no one is logged in via SSH)
View stop-idle-azure.py
# This is how the cron file should look like.
# PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/sn$
# * * * * * /home/script/stop-idle-azure.py > /tmp/user_error.log
## Watchout, for some reason cron files seem to require an extra new line at the end,
## consult this SO: https://askubuntu.com/questions/23009/why-crontab-scripts-are-not-working
## Also take care to setup a PATH variable for the cron explicitly. It doesn't see
## your regular PATH variable.