'Stay awake' functionality for server

Hello

I am running Opensuse 11.1 on a mini home server, with a maximum of two client PCs. For 18 or more hours a day, neither client is connected. I would really like some way of having the server run only when needed, and sleep the rest of the time.

I’ve implemented WOL to get the server woken up with no problem, but I would like some mechanism to keep the server awake only when one or more of the clients is connected. Is this a simple thing to do? Could some process intermittently check to see if a client is connected, and put the server to sleep if not? Is that a simple thing to implement ? (I’m not very experienced at scripting). Is there a better / more obvious way to do it?

Thanks for any suggestions or pointers

You don’t say what kind of server. Samba server, web server, ftp server?

If Samba server you could periodically check the output of smbstatus to see if there are any connections.

Samba server. So, is it easy to do this with a script? Apologies if this seems obvious!

Take the output of smbstatus and look for any connected clients. If none, then the server can be shutdown.

Thanks for your response. And if clients are still connected, do you know how I can reset the ‘machine idle’ (ie no keyboard/mouse activity) timer to zero? Is this maintained by the desktop or by X-windows?

Don’t really know. Maybe you can poke the X server using the xset program.