Script Help - Keeping The Drobo Awake!

Soldato
Joined
18 Oct 2002
Posts
8,453
Hey Guys,

I was wondering if someone can help me figure out this script:

http://blog.nuthatch.com/post/280554023/keep-drobo-from-sleeping

http://blog.bobwalder.com/post/291761046/keep-drobo-from-sleeping

Both are the same, wether one ripped it from the other....

Seems simple but after I copy/paste the text into a TextEdit file on the Drobo, and run the command in Terminal nothing happens?

Tried running it in Apple Script, but it doesnt like 'which'

Any ideas, or explain it to me in a different way?

Cheers!
 
This is Unix bash rather than apple script (although it would be possible todo this in applescript too).

A unix shell script is a text file that starts with "#!/mypath/myshell" and has the execution file permission set. The first link is better as it explains it better.

1. Copy this bit into a text file with the full name of /Volumes/Drobo/nosleep":
#!/bin/bash
while [ true ]; do
# Keep Drobo from sleeping
touch /Volumes/Drobo/nosleep
sleep 300
done

2. Next make the text file executable using the following command at a terminal prompt:
chmod +x /Volumes/Drobo/nosleep

3. Then all that is left todo is start it so it runs in the background:
/Volumes/Drobo/nosleep &

The '&' on the unix command line will make the system run the command as a separate process. This means your command prompt will return back to you but in the background the system is running your 'nosleep' command as a process. You'll not need to worry about it unless you want to disable the drive etc.

The 'ps' command displays lists of processes or information about them. It's an easy way to check it's running.

Note that you will need to restart the script manually or by placing in the startup location.
 
Would this kind of thing work on normal Firewire or USB external drives too? It kind of irritates me that sometimes finder or a save prompt will completely freeze while my external hard drive spins up.
 
I don't see why not!

Cheers Nick, just one thing....how do I add it to my startup? Login Items under Sys Pref / Accounts?

Thanks again!!!!
 
Cheers Nick, just one thing....how do I add it to my startup? Login Items under Sys Pref / Accounts?

Todo this properly is a little more complicated. If you look under "System Startup Programming Topics" within the OSX developer library it'll detail it.

I can create one of these startup items but I won't have time this morning.
 
Last edited:
Would this kind of thing work on normal Firewire or USB external drives too? It kind of irritates me that sometimes finder or a save prompt will completely freeze while my external hard drive spins up.

Would also like to know this.

A lot of the time when I put my iMac to sleep the external drive spins up and throws up the 'did not eject error' which is bloody annoying.
 
I leave my 3 external firewire 800 drives unplugged for this very reason...slows down the computer :/
 
Short answer - yes. It can be done for each drive regardless of connection.

All the script does is update the modified date of the script itself every 300 seconds. So the drive sees it's getting prodded and doesn't decide to sleep.

*twiddles thumbs waiting for 4beta4 to DL* 40 mins..

The complication is that the program will continue to prod the drive.. so if you eject it then it will write it's complaint to the system log.. lastly what you really want is to allow the drive to sleep if you're not using the machine but soon as you login or interrupt the screensaver it starts prodding the drive again.
 
Last edited:
I think there may be an easy way to start up the script each time you login.. System Preferences > Accounts then add the /Volumes/Drobo/nosleep under the "Login items" tab.
I just need to test it first.. but that requires me to log out which I can't at the moment.

That'll work... if you make a script command to spawn itself..

Code:
#!/bin/bash
# Updated version with an auto-spawn and return so that
# users can just add it to their OSX Login items

if [ -n "$1" -a "$1" == "start" ] 
then
while [ true ]; do
touch $0
sleep 300
done
else
$0 start &
fi

# end of school script (don't forget the new line!)

When this command is run, it does the /Volume/.../nosleep & for you. Just going to test the login items out... brb..
 
Last edited:
Well it does work but it still leaves terminal window open (OSX runs it in terminal :/). The window and even terminal can be quit.. it's just annoying it runs terminal..

I looked at applescript and automator.. both were more hassle.

Anyway, it's there if you want the new improved version that works with 'login items'. I dare say an applescript could also be run to 'tell "Terminal" to close all windows and quit" somehow..
 
Last edited:
Cheers Nick but ya kinda lost me here lol.

I know the basic script works but like you say doesnt rerun when I turn on the computer, even after adding it to my open items, it just opens the text file....What is it I should do with the script you've done above?

Thanks
 
Replace the original script with the code I have quoted. Then save as "nosleep" (without .txt).

Then make the command executable by running the "chmod +x /Volume/.../nosleep" command on it from the terminal prompt.

The problem with my 'improved script' is that it leaves the terminal window up after login.. you can Quit terminal and the open window without stopping the process.

The last alternative is to make a launchd item but that's even more fun.. but not tonight!
 
Back
Top Bottom