Some external hard drives (Western Digital among them) do not respect MacOS' Energy Saver setting s and will spin down even if the OS settings say not to.
There's a shareware app called Keep Drives Spinning that updates/pokes a small file on each external drive every 60 seconds to trick them into not sleeping. Rather than installing someone else's kludgy freeware, I was wondering if this is something KM could do, giving me complete control of the process?
Would copying and deleting a file do the trick? Any way of determining the longest viable interval aside from experimentation? Any suggestions?
Thanks.
UPDATE: I found this script on the web, but it's way above my pay grade. Would launching this script from KM every five minutes or so do the trick?
#!/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.
Thanks for your help.
Sure, something like this:
Keep Drive Spinning.kmmacros (3.0 KB)
For some volumes you may not be able to write to the root of the volume like that, so you might have to find a writable location on the volume. But for ordinary mountable drives it shouldn't be a problem.
1 Like
Thanks, @peternlewis . If I have spaces in the drive name, do I need to escape them with\ in the shell script?
You could put the path in quotes.
Like this:
touch "/Volumes/HDD with spaces in name/.hiddenfile"
3 Likes
Yes, you have to quote them somehow. Any of these would work:
touch /Volume/My\ Drive/.hiddenfile
touch /Volume/"My Drive"/.hiddenfile
touch "/Volume/My Drive/.hiddenfile"
Note that is the path begins with a ~, you cannot quote that, so for those kinds of paths you could do either the first two, but not the last one, though you could do something like:
touch ~/"Documents/My File.txt"
But in this case that's not an issue since you are using an absolute path to specify the file in the script.
2 Likes
Thanks very much. I got it working, now I just need to tune it with the right interval.
1 Like