This script suspends a computer based on the network activity.
This is useful, if you have a server that is accessed rarely and that is able to wake on unicast packets.
It was written for a proof of concept, that servers can be suspended in order to save resources.
Executable scripts in the directories
autosuspend.post/ will be run
(guess what) right before and after suspending.
$ chmod +x …) and disable (
$ chmod -x …) them as you wish.
Scripts exiting with an exit status other than
prevent the machine from suspending.
Every script will receive the interface we are listening on as the first argument.
for best success, read the how-to
install Python 3.
clone this repository
$ git clone https://github.com/lpirl/autosuspend.git
$ /path/to/autosuspend.py --helpand choose your desired options
go to the checked-out directory
install autosuspend to
$ make install
if you want a systemd service to be installed, run
$ make install_systemd_serviceas well
edit the created file
autosuspend.serviceto your liking
(if you do, run
$ systemctl daemon-reloadafterwards)
Put something like this in your crontab:
@reboot nice -n 10 /path/to/autosuspend.py [your options] [your device] &
You can run
$ ./autosuspend.py -d [other options] [your device] to see why your machine is [not] suspending.