
Mar 18, '09 07:30:00AM • Contributed by: balkce
A workaround for this is to not let the hard drive be inactive for more than five minutes by constantly touching a hidden file on the hard drive. This is done by first building a small script in bash that touches the hidden file and that also checks if the hard drive is mounted, so as to not flood the system logs if the drive isn't connected. Here's that code:
#!/bin/bash
# Used to not let a volume named MYBOOK sleep
volpresent=$(mount | grep MYBOOK | wc -c)
if [ $volpresent -gt 0 ]
then
touch /Volumes/MYBOOK/.hiddenfile
fi
This script should be made executable by running the following on the Terminal: chmod +x ./no_sleep_script.sh. Replace no_sleep_script.sh with whatever you named the script. The best way to run this script every five minutes is to use the launchd system built into Mac OS X, and a donationware app called Lingon is a great tool to manage it.
Install Lingon, then build a new Agent in the My Agents category, choose a unique name for it (such as com.username.agentname), input the location of the script, and tell it to run it every five minutes. Save it and restart your session. I've done this and the drive has remained sleepless since.
It can be argued that this may shorten the life of the HD, but from what I've read in various forums, having the HD spinning down and up constantly also causes severe strain on the HD, especially in situations like mine where the HD is constantly on. DISCLAIMER: This is not really my hint, but a variation of someone else's, but I don't remember where I got it from, sorry!