使用电源管理

附录 A 使用命令行配置电源管理

本章阐述如何在未配置运行 CDE 或 OpenWindows 环境的系统上改变"电源管理"实用 程序的系统默认设置。另外,亦可编辑 /etc/power.conf 文件从而以通过 dtpower 用户接口无法设置的一些方法来改变系统闲置的定义。


注意:

请参阅 power.conf(4) 手册页上有关的更多信息。


闲置定义

在"电源管理"软件的早期版本中,对系统不活动状态仅依据自最后一次键盘或鼠标动作以来的时间量而定义。现在,则也考虑机器活动的其它方面。默认情况下,当以下所有条件都满足时才认为机器为不活动:

若要从这些默认值来改变闲置定义,请参见 "改变闲置定义"


注意:

在 CDE 中运行除空白屏幕选项之外的其它屏幕保护图案可能产生额外的系统活动,从而阻止系统因足够的闲置时间而 AutoShutdown(自动关机)。要使运行屏幕保护图案的系统在达到指定闲置时间时能自动关机,可能需要改变加载平均值或磁盘读取的阈值设置。


power.conf 文件

/etc 目录下的 power.conf 文件让用户设置管理系统电源的配置。该文件还让用户能设定显示器电源配置;当没有 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: 根口令
    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 文件中定义的阈值将新的设定值通知了"电源管理"框架。

设置自动关机

改变自动关机时间
  1. 作为超级用户,编辑 /etc/power.conf 文件中的 AutoShutdown(自动关机)条目。键入:

    example# vi /etc/power.conf

    通过在 /etc/power.conf 文件中如下所示部分输入相同的"开始"和"结束"时间值,自动关机功能被设定为"总是"准备就绪以激活。这意味着在一天中的任何时间,若有 30 分钟的不活动期之后系统即关闭电源。


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

    以下所示在 /etc/power.conf 文件中此部分的自动关机时间设置为每天下午 5:30 至上午 8:00 之间在 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>

使用正文来定义闲置

可以创建正文来测试一些附加标准;满足这些标准后,才在系统被认为处于不活动状态已足够长的时间,应引发自动关机。当已满足所有其他闲置标准后, /etc/power.conf文件中的idlecheck条目使您在该条目中列出的正文运行。

例如,若系统其 /etc/power.conf 文件中有以下 idlecheck 行,则在根据 power.conf 文件中定义的所有其他标准而已处于闲置时即在该系统上运行位于 /home/grumpy 目录中的正文:


# 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 文件中列在 Autoshutdown(自动关机)条目的闲置时间,系统将关 机。如果正文报告的分钟数小于规定的闲置时间,系统将不会关机。


注意:

在为 idlecheck 创建如此的正文时,务必确保它是可执行的并返回退出代码。如果正文未产生明确退出代码,则返回零值,表明系统繁忙,不发生关机。


改变状态文件的位置

当系统被暂停时,"暂停-继续"软件创建一份状态文件来保留系统关机时刻有关该系统的检查点信息。可以指定此状态文件的任何 UFS 位置,方法是编辑 /etc/power.conf 文件以包括如下格式的条目:

statefile location

对于 location(位置),请提供本地 UFS 文件的绝对路径名。

在此位置上创建的文件其大小取决于各种因素,包括系统内存的大小、正在使用的可加载驱动程序或模块的数目、运行中的进程之数目和类型、以及已被"锁定"的用户内存量。

一个系统上两台监视器的电源管理

如果工作站有两台监视器(有时称作"双头系统"),对两台显示器的"电源管理"控制通过 CDE 和 OpenWindows 窗口环境得到支持。不再需要编辑 /etc/power.conf 文件来提供对第二台监视器的支持。