I recently installed Ubuntu 12.04 Server and am looking for away for get the server to suspend after an idle time. When using the desktop version I could use the Gnome powersaving tool to specify the idle time. As I have no GUI on the server is there a way to set the server idle time via the commandline/config file?
I will send the server a wake-on-lan packet to wake it up, if it is suspended and I need to use it.
OK, there is the hibernate program, which can send your computer to suspend or hibernate from commandline. Determine if your computer is "idle" is going to be trickier.
On a graphical desktop you would use mouse and keyboard input. Obviously in this scenario this is out of the question.
You should start by writing a shellscript, doing some custom idle checks. You can call this script via a cron job every 5 minutes or so.
You could consider your server idle, if no users are logged in (check this with
who
) or if there are no network connections in use (check withnetstat
) or if the cpu load is low (check for example withtop -n 1 -b
). You will have to find your own heuristics.If you go to System>Preferences>Screensaver you can set the idle time there. Just set the preferred time on the bar! Plus if you want to set the picture it's on the same menu.
Jago Gardiner