Skip to content

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

License

Notifications You must be signed in to change notification settings

ostaszewskik/autosleep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages