I was wondering if it were posible to make my server go to sleep after a set period of time, but still be listening for lan requests. I use my server as a media server that might get used 3 or 4 hours a day and it is really a waste of power to have it running all the time. However I don't want to run up to the second floor to switch it on when we want to watch a movie. I saw a few posts about stopping this from happening but how do you enable it?
Wake on LAN is a BIOS and NIC feature, not an OS feature, that is, you need a supporting BIOS and NIC to do it.
Once you've enabled it in your BIOS (if you can), you can check if your NIC has WOL support enabled by checking the output of
If the value of
To check if it is actually enabled, take a look at the value of
If it isn't enabled, run the following:
You'll have to issue this command every time your system starts, so add it to the appropriate place. In Ubuntu, perhaps the best place would be as an
I know this was asked a year ago, but I've found a few solutions. The first one uses
Second I saw online was linux questions. This uses pings to another machine.
I also flashed a router with DD-WRT to try out- at the dd-wrt wiki. These are very nice elegant solutions but the issue I had with them is they are not suited for an internal media server, because the log only catches accepted packets from outside of the network. If you want an internal only media server this just doesn't work.
For dd-wrt this offers a really nice solution to this using VLAN's. Basically put the server on it's own internal subnet and monitor traffic to that VLAN, then the previous script works. This works well, but in my experience the router and build of dd-wrt whenever I used the vlan feature DHCP crashed.
I decided I wanted a solution to wake and suspend my media server automatically when accessed that wasn't dependent on dd-wrt. I have a raspberry pi so I used that. The final solution I found for myself was writing a little bash script. The raspberry-pi dependencies are etherwake and tcpdump. Both are not installed by default on rasbian.
The wake script is as follows:
The primary idea is that it is run from my raspberry-pi which will wake the server if it notices a single arp request for the server. If the server is awake then it wont be listening for an arp request but send a few pings every now and then to make sure it is still awake.
I named the file wol.sh and made it executable. Then put it in the sudo crontab to launch @reboot as root. This is for tcpdump which needs elevated access to listen to eth0 and etherwake.
add this to the bottom
The sleep script is run from the media server using the same principle. If there is no traffic to the server(excluding icmp or arp) during the interval of scanning I chose 1 minute. Then it adds to a counter which I named sleepiness. After the sleepiness reaches 10 or 20 meaning its had no traffic in and out for twenty minutes then it sets the sleepiness to zero then it issues the command
This is maybe not the best because it has to call tcpdump on both machines, Involves constant writes to disk (server side). For the writes to disk I mounted a sacrificial usb and that's where my capture file is saved to prevent wear to my actual HDD. I am a beginner, but I was proud of my little solution.