Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get a CentOS 5.4 server to hibernate when the system has been inactive for a while. By inactive I mean there are no incoming network connections.

I can get the system to hibernate and also make it wake-up over the network. What I need to know is how to configure the system to monitor the network traffic and go into hibernation after a while, say 2 hours.

share|improve this question
Why exactly would you want to put a server in hybernation?!? – Massimo Feb 21 '10 at 13:15
Because it's not used all the time and I don't like wasting energy. There's no use in keeping an (internal) server running when everybody with access to the server is a sleep. – Marnix van Valen Feb 21 '10 at 14:09
+1 interesting idea – Patrick R Feb 21 '10 at 15:34
Did you ever able to achieve this? I'm trying to do the same thing as you but didn't able to get to that point yet. Could you provide some more info if you have already done this. Cheers!! – La Scavenger Jun 12 '11 at 9:43
@Scavenger No, I never got this to work. Please let me know if you get any further. – Marnix van Valen Jun 12 '11 at 18:53

If it is a server, then which services needs to be up? If you serve HTTP only and need SSH also, just monitor HTTP, HTTPS and SSH traffic and if it is idle for more than X minutes hibernate it. You can use tshark to check this.

share|improve this answer
I've been looking into tshark. I'm not sure how I can use it to get the info needed to decide when to hibernate. Could you give me an example? – Marnix van Valen Feb 21 '10 at 20:27
Something like: i=5;while [ $i -gt 0 ];do sudo tshark -npa duration:5 -i lo dst host and dst port 80 2>&1|grep "^0 "||exit;echo -n $i " ";i=$(( $i - 1 ));done; But I think that the best way is to use iptables with LOG target. – Mircea Vutcovici Feb 22 '10 at 1:27
iptables with a LOG target sounds good since iptables is already running on the machine. Care to help me on my way some more sample scripts? Shell scripting is not exactly my area of expertise.... – Marnix van Valen Feb 23 '10 at 21:25

How good are your scripting skills? (or server monitoring system)

You may be able to get away with sampling the TX/RX bytes on your ethernet interface(capture the output of ifconfig, or parse /proc/net/dev), and if it's lower than a certain threshold after 1 hr, initiate the hibernation sequence?

I'm not aware of an out-of-the-box solution for something like this, but I can see how something like this would be useful. Google has many data centers, and move load + power consumption to areas that are active @ that time of day.

share|improve this answer
Don't think TX/RX bytes will do it. There's always some traffic like ARP and SMB. I definitely will need some filtering. – Marnix van Valen Feb 23 '10 at 21:23
Right --- there's always background traffic, I guess depending on how much traffic 'normal' load creates compared to 'idle' load --- if the difference isn't large enough just counting rx/tx won't work. – Jason Feb 24 '10 at 0:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.