forked from km4ack/pi-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatt-test
More file actions
51 lines (43 loc) · 1.19 KB
/
batt-test
File metadata and controls
51 lines (43 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
#This script will help when testing battery duration running a raspberry pi.
#29SEPT2020 KM4ACK
x=1
DATE=$(date)
FILEDATE=$(date +%d%b%Y-%H%M%S)
FILE=$HOME/Desktop/batterytest-$FILEDATE.txt
cat <<EOF
Running a pi until a power failure has the potential
to corrupt the SD card. It is recommended that you
back up your SD card before using this script.
EOF
read -p "Continue? y/n " ANS
if [ $ANS != 'y' ] && [ $ANS != 'Y' ];then
exit
fi
clear
echo "********************************"
echo "********Whole hours ONLY********"
echo "********************************"
read -p "How many hours should we run the test? " ANS
echo
read -p "Auto shutdown when test completes? y/n " SHUTANS
MIN=$(($ANS*60))
CYCLES=$(($MIN/10+1))
echo "Test started at $DATE" >> $FILE
echo "Test set to run for $ANS hours" >> $FILE
while [ $x -le "$CYCLES" ]
do
clear
date >> $FILE
TESTTIME=$(($x*10-10))
echo;echo;echo "Time in 10 minute increments"
echo "Minutes since test began $TESTTIME"
echo "Cycle number - $x"
echo;echo "Press ctrl+c to abort"
x=$(( $x + 1 ))
sleep 600
done
echo "Test ended before battery depleted" >> $FILE
if [ $SHUTANS = 'y' ] || [ $SHUTANS = 'Y' ]; then
sudo shutdown -h now
fi