Last active
August 29, 2015 14:19
-
-
Save NigoroJr/07af97be9f3b67e561b7 to your computer and use it in GitHub Desktop.
Quick-and-dirty script to find out the spin-down time of my external HDD
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
#!/usr/bin/env ruby | |
require 'benchmark' | |
# Access HDD (on /dev/sdb?) | |
# If it takes too long to respond, it has spun down | |
CMD = 'ls /data/Videos >/dev/null' | |
# Range of minutes to wait. Spin-down should be within this range | |
WAIT_MINS = [44, 45] | |
# If it takes longer than this (secnods), disk has spun down | |
THRESH = 3 | |
WAIT_MINS.each do |m| | |
puts "waiting for #{m} mins" | |
sleep 60 * m | |
dur = Benchmark.realtime { system(CMD) } | |
print '=> ' | |
if dur > THRESH | |
puts "spin-down is #{m} mins!" | |
break | |
else | |
puts "Passed #{m} mins but not yet" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment