Skip to content
Bash script that automatically suspends idle home server to save electricity.
Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
autosleep.sh

README.md

Autosleep

Bash script that automatically suspends idle home server to save electricity.

How it works

It measures an in/outbound network traffic and logs in given intervals. If the amount of data sent from the server don't exceeds a set limit, the server suspends itself. It's a very useful script intended to use in home servers that are not meant to be turned on constantly.

You can 'wake' your home server using wakeonlan tool by typing:

wakeonlan [server's MAC address]

And after the transmission (video streaming, file syncynig, torrent download) is ended it will suspend itself.

Setup

On Debian-based system you need to add a rule to sudoers file (sudo visudo):

user ALL=(ALL) NOPASSWD: /usr/sbin/pm-suspend

to be able to execute te script correctly. Then setup a cron job like this:

crontab -e
*/15 **** sh /path/to/autosleep.sh

2017: added signed tag

License

This is just a modified version of a script I found in Ubuntu Forums, originally posted by the user vashwood. I claim no copyright to it.

You can’t perform that action at this time.