Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple little script to keep my external drive spinning as it likes to go to sleep... lots...
#!/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:
puts <<WELCOME
** Drive Spinner ****
# 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
# break out of the loop
puts "File looks like it's not writeable, is the drive mounted?\n\r"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment