如何讓server的螢幕關閉電源? - Linux

By Steve
at 2010-12-24T17:39
at 2010-12-24T17:39
Table of Contents
注意!!! 請確認你沒有啟動 X 再嘗試以下動作
請參考 man console_codes 其中這段:
Linux Console Private CSI Sequences
The following sequences are neither ECMA-48 nor native VT102. They are
native to the Linux console driver. Colors are in SGR parameters: 0 =
black, 1 = red, 2 = green, 3 = brown, 4 = blue, 5 = magenta, 6 = cyan,
7 = white.
ESC [ 1 ; n ] Set color n as the underline color
ESC [ 2 ; n ] Set color n as the dim color
ESC [ 8 ] Make the current color pair the default attributes.
ESC [ 9 ; n ] Set screen blank timeout to n minutes.
ESC [ 10 ; n ] Set bell frequency in Hz.
ESC [ 11 ; n ] Set bell duration in msec.
ESC [ 12 ; n ] Bring specified console to the front.
ESC [ 13 ] Unblank the screen.
ESC [ 14 ; n ] Set the VESA powerdown interval in minutes.
請以 root 的權限執行以下命令:
echo -e "\033[9;1]" > /dev/console
echo -e "\033[14;1]" > /dev/console
之後閒置一分鐘, 畫面會變黑, 再過一分鐘, 螢幕關機.
或者也可以試試 setterm, 詳細請 man setterm 尋找其中 VESA 段落.
以上兩種方法其實都是透過 kernel DPMS 來關閉螢幕, 很不幸的
網路上看到許多回報 screen blank 正常, screen powerdown 沒有作用,
我不確定這是 kernel 的 bug 或是硬體的問題.
如果你也屬於有問題的一員, 請再試試以下方法:
使用 vbetool 關閉螢幕( vbe 是 VESA BIOS Extension 的縮寫)
請注意最後這個方法並不是設定一個閒置的時間自動關閉螢幕,
也就是以 vbetool 關閉螢幕就要摸黑操作了.
我的解決辦法是連結到 Alt-UpArrow 功能鍵, 把以下內容存到 /usr/sbin/dpms
#!/bin/bash
touch /var/dpms
state=$(< /var/dpms)
case "$state" in
off) state=on ;;
*) state=off ;;
esac
echo $state > /var/dpms
vbetool $state
修改 /etc/inittab 加入以下這行
kb::kbrequest:/usr/sbin/dpms
執行 telinit q 使新的 inittab 生效, 之後就可以按 Alt-UpArrow 開關螢幕了
※ 引述《uwmtsa5566 (名人)》之銘言:
: 我灌了一部Ubuntu Server
: 只跑 text console
: 發現這部主機的螢幕會一整天都在亮
: 就算很久一段時間沒動
: 畫面只是變黑
: 並沒有關閉螢幕電源
: 像這種當server用的主機
: 希望設定一段時間之後
: 能自動關閉螢幕電源
: 該怎麼做?
--
A quotation from the movie "The Se7en":
Ernest Hemingway once wrote that,
"The world is a fine place and worth fighting for."
I agree with the second part.
--
請參考 man console_codes 其中這段:
Linux Console Private CSI Sequences
The following sequences are neither ECMA-48 nor native VT102. They are
native to the Linux console driver. Colors are in SGR parameters: 0 =
black, 1 = red, 2 = green, 3 = brown, 4 = blue, 5 = magenta, 6 = cyan,
7 = white.
ESC [ 1 ; n ] Set color n as the underline color
ESC [ 2 ; n ] Set color n as the dim color
ESC [ 8 ] Make the current color pair the default attributes.
ESC [ 9 ; n ] Set screen blank timeout to n minutes.
ESC [ 10 ; n ] Set bell frequency in Hz.
ESC [ 11 ; n ] Set bell duration in msec.
ESC [ 12 ; n ] Bring specified console to the front.
ESC [ 13 ] Unblank the screen.
ESC [ 14 ; n ] Set the VESA powerdown interval in minutes.
請以 root 的權限執行以下命令:
echo -e "\033[9;1]" > /dev/console
echo -e "\033[14;1]" > /dev/console
之後閒置一分鐘, 畫面會變黑, 再過一分鐘, 螢幕關機.
或者也可以試試 setterm, 詳細請 man setterm 尋找其中 VESA 段落.
以上兩種方法其實都是透過 kernel DPMS 來關閉螢幕, 很不幸的
網路上看到許多回報 screen blank 正常, screen powerdown 沒有作用,
我不確定這是 kernel 的 bug 或是硬體的問題.
如果你也屬於有問題的一員, 請再試試以下方法:
使用 vbetool 關閉螢幕( vbe 是 VESA BIOS Extension 的縮寫)
請注意最後這個方法並不是設定一個閒置的時間自動關閉螢幕,
也就是以 vbetool 關閉螢幕就要摸黑操作了.
我的解決辦法是連結到 Alt-UpArrow 功能鍵, 把以下內容存到 /usr/sbin/dpms
#!/bin/bash
touch /var/dpms
state=$(< /var/dpms)
case "$state" in
off) state=on ;;
*) state=off ;;
esac
echo $state > /var/dpms
vbetool $state
修改 /etc/inittab 加入以下這行
kb::kbrequest:/usr/sbin/dpms
執行 telinit q 使新的 inittab 生效, 之後就可以按 Alt-UpArrow 開關螢幕了
※ 引述《uwmtsa5566 (名人)》之銘言:
: 我灌了一部Ubuntu Server
: 只跑 text console
: 發現這部主機的螢幕會一整天都在亮
: 就算很久一段時間沒動
: 畫面只是變黑
: 並沒有關閉螢幕電源
: 像這種當server用的主機
: 希望設定一段時間之後
: 能自動關閉螢幕電源
: 該怎麼做?
--
A quotation from the movie "The Se7en":
Ernest Hemingway once wrote that,
"The world is a fine place and worth fighting for."
I agree with the second part.
--
Tags:
Linux
All Comments
Related Posts
lenny直上squeeze,讓我差點以為收藏都掰了.

By Madame
at 2010-12-24T10:36
at 2010-12-24T10:36
isz

By Rebecca
at 2010-12-24T09:39
at 2010-12-24T09:39
在windows下使用ubuntu的環境來寫程式

By Dora
at 2010-12-24T01:44
at 2010-12-24T01:44
CentOS 5.5 useradd 出現command not found

By Agnes
at 2010-12-24T00:53
at 2010-12-24T00:53
支援Unicode的 FTP server?

By Dora
at 2010-12-24T00:51
at 2010-12-24T00:51