電源管理功能的使用方法

附錄 A 利用指令行來配置電源管理

本章說明針對在沒有配置來執行CDE或OpenWindows環境的系統中,如何更改它們「電源管理」公用程式的系統內定值。此外您也可以編輯/etc/power.conf 檔案,來變更系統的閒置定義,它能用dtpower使用者介面做不到的方式,來變更閒置的定義。


註解 -

請參閱power.conf(4)的線上援助頁,以獲得更多的資訊。


閒置的定義

在「電源管理」軟體較早的版次中,所謂的系統“不在作用中”指的只單單是從最後一次的鍵盤或滑鼠活動到目前的這一段時間;而如今系統的其他活動也跟著考慮進去。依據內定值,當所有以下情況發生時,表示系統不在作用中:

若要變更這些內定值的閒置定義,請參閱"變更閒置定義"


註解 -

在CDE執行非空白螢幕選項的螢幕保護程式圖樣時,可能會造成額外的系統活動,使得系統無法閒置過久,而無法符合「自動關機」的條件。要讓執行螢幕保護圖樣的系統能在指定的閒置時間過後「自動關機」,您可能需要變更工作量平均或磁碟讀取的臨界值。


power.conf 檔案

power.conf檔案(在/etc 目錄中)可讓您進行系統電源的管理配置。當系統不在CDE或OpenWindows桌面的環境時,這個檔案還能讓您配置顯示器的電源。(請參閱第 2章, 監視器電源的管理 ,以獲得在那些視窗環境下管理顯示器電源的詳細資訊。)

內定的/etc/power.conf檔案內容如下:


# Power Management Configuration File

#

# Putting an entry in this file will only be effective if the 

# driver for the device supports device power management. 

# After the file is modified, pmconfig(1M) command must be

# executed to activate the new change.

#

# Fields must be separated by white space or semicolons.

# Note that physical dependents are automatically considered

# by the power management framework.

# Name      Threshold(s)        Logical Dependent(s)

/dev/kbd         1800

/dev/mouse       1800



# NOTE: The entries below are only used when no window

# system is running. When running the window system, monitor

# power management is done by the screen saver functions.



/dev/fb           0 0               /dev/kbd     /dev/mouse



# Auto-Shutdown  Idle(min)  Start/finish(hh:mm)  Behavior

autoshutdown     30           9:00 9:00             default



statefile         /.CPR>

邏輯相依單元

/etc/power.conf檔案中有邏輯相依單元(Logical Dependent)的項目。 每一個項目都是一個實際裝置(像是滑鼠),而其活動和另一個裝置(像是框架緩衝器)相關,但並未實際連接在一起。

如果某個邏輯相依單元的裝置在作用中的話,那麼主要的裝置也被認為是在作用中。因此它會影響這個主要裝置的閒置時間。

變成高階使用者

要使用本節的程序來更改任何的系統內定值,首先您必須成為高階使用者。

如何成為高階使用者
  1. 鍵入:


    example% su
    
    Password: root password
    
    example#

設定裝置閒置時間

您可指定系統裝置(例如是螢幕)開始省電模式前,應先閒置的時間。做法是變更/etc/power.conf檔案的臨界值的欄位。

變更閒置時間的長度
  1. 以高階使用者的身份,編輯/etc/power.conf 檔案。鍵入:

    example# vi /etc/power.conf

  2. 修改相關的項目。

    如下所示,在/etc/power.conf 檔案中,鍵盤和滑鼠裝置的閒置臨界值已修改為300秒(5分鐘)。


    # Power Management Configuration File
    
    #
    
    # Putting an entry in this file will only be effective if the 
    
    # driver for the device supports device power management. 
    
    # After the file is modified, pmconfig(1M) command must be
    
    # executed to activate the new change.
    
    #
    
    # Fields must be separated by white space or semicolons.
    
    # Note that physical dependents are automatically considered
    
    # by the power management framework.
    
    # Name           Threshold(s)        Logical Dependent(s)
    
    /dev/kbd         300
    
    /dev/mouse       300
    
    
    
    # NOTE: The entries below are only used when no window
    
    # system is running. When running the window system, monitor
    
    # power management is done by the screen saver functions.
    
    
    
    /dev/fb          0 0        /dev/kbd    /dev/mouse
    
    
    
    # Auto-Shutdown  Idle(min)  Start/finish(hh:mm)  Behavior
    
    autoshutdown     30          9:00 9:00           default
    
    
    
    statefile        /.CPR

  3. 鍵入下列文字,讓「電源管理」系統知道新的設定值:

    example# /usr/sbin/pmconfig

    執行pmconfig,依據臨界值,讓「電源管理」系統知道新的設定值,這些臨界值現在定義在/etc/power.conf檔案中。

設定AutoShutdown(自動關機)

變更AutoShutdown(自動關機)時間
  1. 以高階使用者的身份,編輯/etc/power.conf檔案中的AutoShutdown(自動關機)項目。鍵入:

    example# vi /etc/power.conf

    如下/etc/power.conf檔案中的片段所示,如果輸入的開始時間和結束時間一樣的話,AutoShutdown(自動關機)功能便可隨時啟動。也就是說,您的系統不管在任何時候,只要連續30分鐘沒有在作用,系統的電源即會關閉。


    # Auto-Shutdown    Idle(min)    Start/Finish(hh:mm) 
    
       Behavior autoshutdown       30           0:00 0:00 
    
                 shutdown 

    在以下所示/etc/power.conf 的檔案中,AutoShutdown(自動關機)的時間設定在每天下午的五點半到晚上八點之間,只要系統有30分鐘沒有在作用中,就會自動關機。


    註解 -

    輸入power.conf 檔案中的開始和結束時間必須使用24小時的格式。


    # Auto-Shutdown    Idle(min)    Start/Finish(hh:mm) 
    
       Behavior autoshutdown       30           17:30 8:00 
    
                shutdown 


  2. 鍵入下列文字,讓「電源管理」系統知道新的設定值:

    example# /usr/sbin/pmconfig

    執行pmconfig,依據臨界值,讓「電源管理」系統知道新的設定值。這些臨界值現在定義在/etc/power.conf檔案中。

變更閒置定義

您可以從內定值變更系統的閒置定義,做法是將項目加進/etc/power.conf檔案中。這些項目會變更某些系統作業的臨界值,而且它可能會發生在仍然不在作用中的系統上:

但是您無法變更鍵盤或滑鼠活動的臨界值。任何與這兩種裝置相關的活動都會終止系統的閒置期間。

例如在下列情況,您可以修改power.conf檔案,來變更系統的閒置定義,使它仍然被認為是處於閒置的狀態:

所產生的/etc/power.conf檔案如下:


# Power Management Configuration File

#

# Putting an entry in this file will only be effective if the 

# driver for the device supports device power management. 

# After the file is modified, pmconfig(1M) command must be

# executed to activate the new change.

#

# Fields must be separated by white space or semicolons.

# Note that physical dependents are automatically considered

# by the power management framework.

# Name           Threshold(s)       Logical Dependent(s)

/dev/kbd         1800

/dev/mouse       1800



# NOTE: The entries below are only used when no window

# system is running. When running the window system, monitor

# power management is done by the screen saver functions.



/dev/fb          0 0         /dev/kbd     /dev/mouse



# Auto-Shutdown  Idle(min)  Start/finish(hh:mm)  Behavior

autoshutdown     30         15:00 8:00           default



statefile        /.CPR



ttychars            400

diskreads           10

nfsreqs             5

loadaverage         0.1

用指令集定義閒置

您可以寫一個指令集,來測試系統不在作用中多久後才能自動關機的情形,需要哪些額外條件的配合。當所有其它的閒置條件均符合之後,idlecheck(閒置檢查) 項目(在/etc/power.conf檔案中),會開始執行您在該項目所命名的指令集。

例如位於/home/grumpy 目錄的指令集執行的條件是:系統有一行idlecheck (位於/etc/power.conf檔案),且系統已經閒置過一段時間而符合定義在power.conf檔案中的所有其它條件:


# The idlecheck program is passed autoshutdown 

idle time entry 

# in $PM_IDLETIME and returns the number of minutes the system 

# has been idle in exit code

idlecheck          /home/grumpy/idlecheck

您的指令集應該要傳回一個退出碼,代表著閒置的分鐘數。如果退出碼等於或大於列在/etc/power.conf檔案中“自動關機”項目的閒置時間,系統就會關機。若指令集傳回的數字比列出的閒置時間小,系統就不會關機。


註解 -

您在為idlecheck寫上述的指令集時,請注意它要能夠執行,並能夠傳回一個退出碼。如果您寫的指令無法產生一個明確的退出碼,傳回的值將會是0,表示系統在工作中,而不會自動關機。


變更狀態檔位置

當系統暫停時,「暫停-繼續」軟體會建立一個狀態檔(statefile),來保留這個系統在關機時的核對點資訊。您可指定任何的UNIX檔案系統(UFS)的位置給這個狀態檔,方法是編輯/etc/power.conf 檔案,以下面的格式來包含一個項目:

statefile location

location一項,鍵入某個本地UFS檔案的絕對路徑名稱。

在這個位置所建立的檔案之大小,依許多因素決定。包括系統記憶體大小、使用中的可載入驅動程式或模組數目、執行中的處理元個數和類型、以及被“鎖定下來”的使用者記憶體數量。

具雙監視器系統的電源管理

如果您的工作站有兩個監視器(有時稱為“雙監視器系統”),那麼這兩個顯示器的「電源管理」控制是由CDE和OpenWindows視窗化環境支援的。您不再需要編輯/etc/power.conf檔案,來支援第二個螢幕。