Created
November 1, 2015 09:01
-
-
Save ks-t0/c7baf93aa6cd2dfa03b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
disk=$1 | |
interval=$2 | |
state=`grep " $disk " /proc/diskstats` | |
count=$interval | |
up=1 | |
while [ true ]; do | |
sleep 10 | |
count=$(($count-10)) | |
newstate=`grep " $disk " /proc/diskstats` | |
if [ "$state" = "$newstate" ]; then | |
if [ $count -lt 0 ]; then | |
count=$interval | |
if [ $up = 1 ]; then | |
#echo -e "spin-down\t" `date` | |
sync | |
state=`grep " $disk " /proc/diskstats` | |
scsi-stop /dev/$disk | |
up=0 | |
fi | |
fi | |
else | |
#echo -e "drive is up\t" `date` | |
count=$interval | |
state="$newstate" | |
up=1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment