Skip to content

Instantly share code, notes, and snippets.

View christianll9's full-sized avatar

Christian christianll9

  • Bosch Research
  • Germany
View GitHub Profile
@christianll9
christianll9 / stop-idle-gcloud.py
Last active June 18, 2021 08:01 — forked from why-not/stop-idle-azure-aws.py
Automatically Shutting Down Google Cloud VM (when idle AND no one is logged in via SSH)
# BASED on https://gist.github.com/why-not/18c5c0c00ee4cddf5ca176f770918639
# 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-gcloud.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