O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  



Auto Laptop Shutdown
A script for cron to automagicly shutdown your laptop when the battery gets too low.

Contributed by:
destryjaimes
[12/20/05 | Discuss (2) | Link to this hack]

In case I'm not paying attention to my battery monitor hack, or I've simply left my laptop on while it's in my bag, I've written this little script to watch my back. I simply add an entry to root's crontab file to run this script every minute. Since it doesn't do anything CPU intensive, it will not cause any sort of significant load on the machine. If the machine is not on AC power, and the battery is at 5% charge, then it will automaticly shutdown the system ... which is better than just losing power. Simply edit root's crontab file like so ...

95% ~# crontab -e

... and add this line to run the script every minute ...

* * * * * /usr/local/sbin/bat_watch.sh 1> /dev/null

See also:


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.