Potty Page

March 3, 2006

Remotely turning off monitors in Linux

As some of my regulars will know, every night I run a cluster of 72 lab machines to do simulations. Every night I used to have to go around and turn off 72 monitors, much pain in the butt.

This was mainly due to not being able to work how to run the command "setterm -powersave powerdown" on anything that wasn't a real terminal locally at the machine...

ed@porter:~$ setterm -powersave powerdown
cannot (un)set powersave mode

After trawling the web for ages I've come up with commands that'll remotely make your monitor turn off if you're X windows... it goes something along the lines of... although there could be Xauth issues and the like.

ed@porter:~$ xset dpms off

but that doesn't help me, 'cause there's no need on running it on the simulation machines.

Yesterday I had a flash of insipration of how to get it to run on the local console...

porter:~# openvt -- setterm -term linux -powersave powerdown

Simple, huh? You have to run it as root or have write permissions on the virutal terminal you want to use (you can supply which VT to run it on by using the -c option of openvt)

This won't turn off the monitor immediately - it'll do it when the keyboard has been idle for the blanking time and the powersave time - it's simple to make this low...

porter:~# openvt -- setterm -term linux -powerdown 1
porter:~# openvt -- setterm -term linux -blank 1

Hope it helps someone!

Posted by Ed at March 3, 2006 1:04 PM | Geek |