Skip to content

Developing on AWS or GCE

David Taylor edited this page Mar 29, 2016 · 2 revisions

When running benchmarks or resource intensive stress tests, it can be helpful to run on a GCE or AWS instance -- trying to do anything else (even just web browsing) can be difficult, plus laptops have highly variable performance (both due to running other things and hardware doing thermal/power management) making their timings unreliable.

Auto-shutdown when not in use

Since usage is billed by the hour, automatically shutting down when not in use saves $. A cron job can check if you are logged in and start a shutdown if not. Waiting 10mins prevents shutting down before you get a chance to login or if you briefly disconnect, and checking if /.active exists allows easily disabling this temporarily when you want to leave something running unattended.

  1. Put the following in /root/idle.sh:
#!/bin/bash

who=david

# bail if I'm logged in or I've signaled I want to stay running.
if w | grep -q $who || [[ -f /.active ]]; then exit; fi

echo "shutdown in 10 min" | wall
sleep 600

if w | grep -q $who || [[ -f /.active ]]; then exit; fi

/sbin/shutdown -h now
  1. Make it executable: chmod +x /root/idle.sh
  2. Edit root's cron with sudo crontab -e to add:
* * * * * /root/idle.sh 2>&1 >> /root/idle.log
  1. Add sudo rm /.active to your ~/.bashrc (or whatever) to clear the .active file on next login.
  • Home
  • Beta Dashboard
  • Release Process
  • [Building and running tests](Building and running tests)
    • [Using musl to get a completely static binary](Using musl to get a completely static binary)
  • Productivity
    • [Multiple GOPATHs](Multiple GOPATHs)
    • [Ben's Go Emacs setup](Ben's Go Emacs setup)
    • [Radu's vim setup](Radu's vim setup)
    • [Speeding up cgo builds](Speeding up cgo builds)
    • [Rando scripts](Rando scripts)
  • [Life of a transaction](Life of a transaction)
  • Readings
Clone this wiki locally