Skip to content

Instantly share code, notes, and snippets.

View theanht1's full-sized avatar
๐Ÿ‘€

Anh Mai theanht1

๐Ÿ‘€
  • Hanoi, Vietnam
View GitHub Profile
@theanht1
theanht1 / gcp-shutdown.sh
Last active April 20, 2020 08:36 — forked from abraaojs/gcp-shutdown.sh
gcp-shutdown.sh
#!/bin/bash
# Created by abraaojs, updated by theanht1
# Add to instance metadata with `gcloud compute instances add-metadata \
# instance-name --metadata-from-file startup-script=gcp-shutdown.sh` and reboot
# NOTE: requires `bc`, eg, sudo apt-get install bc
# Modified from https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage
threshold=0.1
count=0