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 文件里.
以上就是全文内容,更多内容敬请关注纳讯网络~
领取专属 10元无门槛券
私享最新 技术干货