Skip to content

Instantly share code, notes, and snippets.

@ks-t0
Created November 1, 2015 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ks-t0/c7baf93aa6cd2dfa03b2 to your computer and use it in GitHub Desktop.
Save ks-t0/c7baf93aa6cd2dfa03b2 to your computer and use it in GitHub Desktop.
#!/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