Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upDeveloping on AWS or GCE
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.
-
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
-
Make it executable:
chmod +x /root/idle.sh -
Edit root's cron with
sudo crontab -eto add:* * * * * /root/idle.sh 2>&1 >> /root/idle.log -
Add
sudo rm /.activeto your~/.bashrc(or whatever) to clear the.activefile on next login.