Created
February 23, 2013 14:34
-
-
Save jamesduncombe/5019987 to your computer and use it in GitHub Desktop.
Simple little script to keep my external drive spinning as it likes to go to sleep... lots...
This file contains hidden or 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 | |
# | |
# Keep the external drive spining! | |
# | |
require 'fileutils' | |
# set the name of the file to write | |
FILE = '/Volumes/Drive_Name/.stayawake' | |
# add a welcome message, that strange bit of text clears the screen | |
# SEE: http://stackoverflow.com/questions/10261359/ruby-clear-screen | |
puts <<WELCOME | |
\e[2J\e[f | |
********************* | |
** Drive Spinner **** | |
********************* | |
WELCOME | |
# keep touching a file on the drive every 10 minutes | |
1.upto Float::INFINITY do |i| | |
if File.writable? FILE | |
puts "Keeping the drive spinning... forever...\n\r" if i.eql? 1 | |
# touch file | |
FileUtils.touch FILE | |
# sleep for 10 minutes | |
sleep 600 | |
else | |
# break out of the loop | |
puts "File looks like it's not writeable, is the drive mounted?\n\r" | |
break | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment