Linux的待机命令

linux系统运用的时候经常性要编写一大串指令,今天主要给大家介绍的就是Linux待机命令,有需要的同学们都收录起来吧!

Linux待机命令有

#xset dpms force standby

#xset dpms force off

脚本:

#!/bin/bash

# default display on current host

DISPLAY=:0.0

# find out if DPMS is enabled

STATUS=`/usr/X11R6/bin/xset -display $DISPLAY -q | grep -e 'DPMS is'`

# enable DPMS if disabled

if [ "$STATUS" == " DPMS is Disabled" ]

then

echo "Enabling DPMS ..." >>/etc/acpi/actions/stay.txt

/usr/X11R6/bin/xset -display $DISPLAY +dpms

fi

# find out if the monitor is on

STATUS=`/usr/X11R6/bin/xset -display $DISPLAY -q | grep 'Monitor'`

if [ "$STATUS" == " Monitor is On" ]

then

echo "[`date`] Turning display OFF" >>/etc/acpi/actions/stay.txt

/usr/X11R6/bin/xset -display $DISPLAY dpms force off

else

echo "[`date`] Turning display ON" >>/etc/acpi/actions/stay.txt

/usr/X11R6/bin/xset -display $DISPLAY dpms force on # turn monitor on

/usr/X11R6/bin/xset -display $DISPLAY s activate # un-blank monitor

fi

exit 0

记得每次运行把记录写进/etc/acpi/actions/stay.txt 文件里.

以上就是全文内容,更多内容敬请关注纳讯网络~

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20190824A0C8T700?refer=cp_1026
  • 腾讯「云+社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。

扫码关注云+社区

领取腾讯云代金券