I want to put my Debian Wheezy home server to sleep, if it wasn't accessed through the network for a certain amount of time.
I thought of a bash script that uses netstat to count the number of active connections, sleeps for some seconds, runs netstat again, and so on.
Is there any better way to achieve this without using sleeping every second? Is there any way to react to the event 'incoming network connection' and reset some kind of countdown timer?