Skip to content

Instantly share code, notes, and snippets.

@NigoroJr
Last active August 29, 2015 14:19
Show Gist options
  • Save NigoroJr/07af97be9f3b67e561b7 to your computer and use it in GitHub Desktop.
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
#!/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