Automatic Sleep for DICE

Over the next few weeks, SL6 DICE desktop computers will start falling asleep when idle. The aim is to make them use less energy.

At present most DICE desktops run F13 or SL5 DICE. These computers will not sleep any more than at present. Once they have been upgraded to SL6 they will mostly start sleeping when idle. (If you don’t know what your machine runs, check the login screen.) The upgrade to SL6 will mostly happen over the summer and autumn of 2011.

You may be aware that we prefer DICE machines to remain on at all times. This is because they depend on automatic processes which can happen at any time of the day or night: software packages are changed, user information in LDAP is updated, reboots are triggered and so on.

The automatic updates generally keep the machines in excellent health, but they do have the disadvantage that the computer cannot safely sleep or be switched off when not in use. A number of folk have contacted computer support about this shortcoming. Help is at hand: the LCFG sleep component is being installed on DICE desktops.

It has already been running in the School’s computing labs for some time, and users of the lab machines will have got used to waking a sleeping machine by touching a key or by pressing the machine’s power button. What’s new is that office machines will now start sleeping too, and that their users will have the opportunity to disable or enable sleep, or to have it operate only at certain times.

What The LCFG Sleep Component Does

The short version is that it puts the machine to sleep when idle, but ensures that it will wake in time to run important cron jobs.

More fully, every few minutes the sleep component decides whether the computer is idle or not. It’s idle when all of these conditions are true:

  • There are no important cron jobs currently running, or due to start soon.
  • The “load average” is very low.
  • All interactive shells have been idle for a while.
  • The machine has already been awake for a specified minimum period.
  • There is no X session in progress. (More on this later.)
  • There isn’t an automatic reboot in progress.

An “important” cron job is one that hasn’t been specifically added to an “ignore these cron jobs” list – so your machine will wake safely for your own “cron” jobs, should you create any.

The component’s other important task is to look forward to when the next important cron job is due to run, and set an alarm which will wake the machine in time to run that cron job. This “wake alarm” is set regularly whether or not the machine is subsequently sent to sleep.

What It Doesn’t Do

There is at the moment no remote wake (for instance, Wake On LAN) facility. We have wanted to create one for several years now, but the work has had to compete with other development projects and so far it hasn’t been prioritised highly enough to be done. With the recent greater emphasis on energy saving we hope that we’ll be able to do it soon. In the meantime, automatic sleep could be inconvenient for anyone who likes to login to their office machine from home.

The component doesn’t currently have a reliable way of finding out how long a login session has been inactive, other than looking at the idle times of any interactive shells that happen to be running. For instance, it’s not allowed to find out how long your keyboard or mouse has been idle: that can only be done by you. We’re working on getting round this problem, but until we do, the sleep component will only send a machine to sleep if no X session is running.

However, you can if you like configure your X session to send the machine to sleep when idle. GNOME users can set this up as follows: From the System menu choose Preferences then Power Management (or type gnome-power-preferences). Change the setting Put computer to sleep when inactive for: from Never to a time such as 10 minutes. (This means 10 minutes after the display has been judged to be idle, which itself can be some time after the keyboard or mouse have last been used.) Once you have done this the computer will sleep when idle whether or not an X session is in progress. The LCFG sleep component will still run in the background and will still ensure that the machine wakes in time to run important cron jobs.

Control Sleep On Your Machine

Once the LCFG sleep software is installed and operational you will be able to disable (LCFG controlled) sleep on your machine with the command om sleep disable and enable it again with om sleep enable.

These commands can also be used in cron jobs, and this provides a way of making a computer sleep only when you want it to. For instance, you could automatically disable sleep at the start of a working day and enable it again in the evening. This could be done by running crontab -e and entering this:

HOME=/tmp
30 8 * * Mon-Fri /usr/bin/om sleep disable
0 18 * * Mon-Fri /usr/bin/om sleep enable

Since a sleeping machine will wake to run your cron jobs, this would neatly ensure that the machine would wake at (in this example) half past eight every weekday morning then stay awake until 6pm. After that time it would continue to stay awake until idle, then go to sleep, waking occasionally in the night to run its maintenance processes.

If you have any comments please feel free to leave them here and I’ll respond. If you have any problems or questions once your SL6 DICE machine starts sleeping, contact computing support for help as normal.

About Chris Cooke

Chris Cooke is a Computing Officer in the School of Informatics at the University of Edinburgh. He works in the Managed Platforms Unit.
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

3 Responses to Automatic Sleep for DICE

  1. David Sterratt says:

    This sounds like an excellent step forward. It would be interesting to see a graph of the School’s energy consumption over time, so that we could see what the influence of sleeping PCs is.

    Having just got a PC that’s modern enough to go to sleep properly at home, I’m aware that sleep can have its pitfalls. For example, I was using tar & ssh to transfer a large number of files and the PC went to sleep whilst the transfer was happening, so I had to start again.

    Unfortunately I might have to disable sleep on my PC until Wake-on-LAN arrives, as I do log in from time-to-time and synchronise my home PC with my work PC. However, perhaps I could use some cron work-arounds.

  2. Philip Wadler says:

    After years worrying about the energy cost of leaving machines running, I’m delighted to see this in place.

    The lack of ability to remotely wake a machine will be a severe problem for me and others. It was a low priority when few machines were sleeping, but I hope it will become a high priority now.

  3. Chris Cooke says:

    (I’m so sorry for the delayed response – I think the comment notifications for this blog are going to somebody who’s on holiday!)

    Thanks a lot for the comments.

    Yes, we could certainly do with some kind of remote wake-up facility, and I agree about it being quite important now. Lots people will need it. When I looked at office-based DICE machines recently, perhaps two thirds of them had had a remote login during the previous few weeks.

    Even if all of those people disable sleep on their machines until we have Wake On LAN, we should still get more machines sleeping than do at the moment (currently in offices: practically none at all!).

    We have been doing a few experiments with Wake On LAN and have been identifying technical issues which will need work. We’ve been looking at the possibility of using the University’s WoL service and of developing our own. For technical reasons the latter currently looks easier and quicker, although that could change.

    The prioritisation process for the next round of development will be happening soon so perhaps it won’t be that long before we’re able to get to work in earnest, should the WoL project get the go-ahead.

Leave a Reply