Open Grieves

Open Grieves

Assimilate quickly!

You must comply!

Simple automatic decommisioning

You must readPosted by Magnus Glantz 2015-11-04 12:56:57
Problem: 100000000 servers that are not used in your development or test environmnets.
Solution: Put below script in /etc/cron.daily/. 30 days after installation date, the server will shutdown automatically. You can make this as fancy as you want, but the solution is still fairly simple.

# Date format is 15-01-31

DATEA=$(cat /etc/server-installation-date-gets-put-in-this-file)
DATEB=$(date +%y-%m-%d)

# Calculates number of days between today and installation date
if [ "$(( ($(date --date="$DATEB" +%s) - $(date --date="$DATEA" +%s) )/(60*60*24) ))" -ge 30 ]; then
logger -t auto_decommision "Server has passed it's end date. Halting server."
shutdown -h now

  • Comments(0)

Fill in only if you are not real

The following XHTML tags are allowed: <b>, <br/>, <em>, <i>, <strong>, <u>. CSS styles and Javascript are not permitted.