iamcook84
2015-05-22 03:28 deepin
本帖最后由 iamcook84 于 2015-5-22 14:44 编辑
还是自己来吧,我写了一个,请高人改进。
1、先建立文件 lowbattery:
#!/bin/bash
battery_status=`cat /sys/class/power_supply/BAT1/status`
battery_capacity=`cat /sys/class/power_supply/BAT1/capacity`
if [ "$battery_status" != "Charging" -a "$battery_capacity" -lt "2" ]
then
echo " shutdwon system at `date`.\n" >>$HOME/shutdowntime.txt
/sbin/shutdown -h now
fi
2、#sudo cp lowbattery /usr/bin/lowbattery
3、再建立文件 systemrun:
* * * * * /usr/bin/lowbattery
4、#crontab systemrun
还是自己来吧,我写了一个,请高人改进。
1、先建立文件 lowbattery:
#!/bin/bash
battery_status=`cat /sys/class/power_supply/BAT1/status`
battery_capacity=`cat /sys/class/power_supply/BAT1/capacity`
if [ "$battery_status" != "Charging" -a "$battery_capacity" -lt "2" ]
then
echo " shutdwon system at `date`.\n" >>$HOME/shutdowntime.txt
/sbin/shutdown -h now
fi
2、#sudo cp lowbattery /usr/bin/lowbattery
3、再建立文件 systemrun:
* * * * * /usr/bin/lowbattery
4、#crontab systemrun
Reply Like 0 View the author
2、电量是否过低。
3、如电池供电电量过低自动关机。