Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use a cron job to prevent hard drive spindown System
There has been reported problems with second hard drives (e.g. Maxtor) that repeatedly spin down and then freeze the system for >5 - 6 seconds before they come back to life. This is very annoying. However, it is easy to work around this by creating a "cron job". This will keep your drive up and alive ( sleep).

If you'd like to learn how to use 'cron' to keep your second drive occupied and awake, read the rest of this article.

You must follow the easy steps below in the Terminal as ordinary user (not as root):
  1. create a plain text file with the name "Activate" on your second hard disk (with me it is called "Work" in the directory "Documents"; i.e. /Volumes/Work/Documents/Activate) with the contents:
    cd /
    ls -la > /dev/null
    The last line should be an enter. Change its rights to executable with
    chmod ugo+x Activate
    This shell script does basically nothing important except run quickly.

  2. create a plain text file in your ~/Documents directory with the name "spin" and with the contents:
    [space]sh /Volumes/Work/Documents/Activate<enter>
    (This all should be on one line; it's shown here on two for the sake of narrowness! Of course you should use the tab-key and the enter-key on the indicated <tab> and <enter> places. Please replace "Work" and "Documents" with the names of the directories where you've put the "Activate" file! N.B. there is a space between "sh" and "/Volumes....!!") This "spin" file should be readable for all (chmod ugo+r). It is the material to be read by the crontab and it means basically: run every five minutes the shell script "Activate"

  3. create a plain textfile in your home directory ~ with name ".login" (or add lines to an already existing .login file) and enter the following lines (end with an <enter>!):
    alias cronoff crontab -r
    alias spinoff crontab ~/Documents/spin
Logout of the Terminal and login again (Cmd-"N"). Now by typing "spinoff" you create a cron job that will keep your second hard drive alive by executing a small unimportant script every five minutes. You can kill this cron job with the command "cronoff" (followed by "y"). This could be useful if you want to save your disk life (and energy bills) when keeping the computer powered on while you are away. The drive then will spin down and sleep as was usual before. You can view the actual context of your crontab with the command "crontab -l". You can also kill it manually by "crontab -r".

Hope this helps! Any comments welcome.

  • Currently 3.60 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)

Use a cron job to prevent hard drive spindown | 11 comments | Create New Account
Click here to return to the 'Use a cron job to prevent hard drive spindown' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another way to write the crontab file
Authored by: legruej on Oct 26, '01 12:40:58PM

You can replace the list "5,10,15,20..." that starts the crontab entry with "*/5". (Don't paste the quotes, just what is within them.)
Picky, I know, but easier to change to every 10 or 15 minutes or whatever. For more info on crontabs, check out or man crontab 5 at a terminal.

[ Reply to This | # ]
Authored by: Tom_H on Oct 29, '01 08:23:32PM

Wouldn't it be easier to make a cron job that just ran the touch command on a file on the drive? If the file gets moved or deleted, the touch file will just make a new one, so it would work without needing any other files.
Something like:
*/5<tab>*<tab>*<tab>*<tab>*<tab>[space]touch "My/File.txt"<enter>

[ Reply to This | # ]
Can't get it to work
Authored by: Divander on Jan 21, '02 08:07:53AM

I am very new to UNIX, I followed your instructions exactly, but when it came to logout and login again, typing "spinoff" (without "") it says: spinoff: Command not found.
Please help as I am having the same problem with the harddisk spinning down.

[ Reply to This | # ]
Can't get it to work
Authored by: cgull on Dec 12, '02 06:42:15PM

You might need to type:


in the terminal. It should then work (provided you have placed your new script in a place like: /usr/local/bin or /usr/bin or wherever you $PATH is set. To get a list of that, type:


and next to 'PAT' you should have a list like:


Hope that helps somebody.

[ Reply to This | # ]
Simpler crontab for drive spindown prevention
Authored by: ckgaparajita on May 11, '02 11:56:24AM
The original hint had us creating a shell file which was then run by cron. This isn't necessary, since you can just execute the shell file command directly in the crontab. The easiest way to edit crontabs is with the excellent freeware utility Cronnix. It can be downloaded from VersionTracker. Once in Cronnix, do the following: 1. Click New to create a new crontab task. 2. Enter "*" (without the quotes) in the Min, Hour, Mday, Month, and Wday columns. This runs the task every minute. 3. If the drive you want to fix is the boot volume, enter:
     ls / > /dev/null
in the Command column. If the drive you want to fix is not the boot volume, enter:
     ls /Volumes/MyVolume > /dev/null
in the Command column, replacing "MyVolume" with the name of any volume on the target drive. 4. Click Save and then quit Cronnix. That is all you need to do to stop drive spindown. Works like a charm!

[ Reply to This | # ]
Doesn't seem to work for me...
Authored by: Ryan0751 on Oct 12, '02 12:05:17PM
I tried to set this up with 10.2, and it doesn't seem to prevent my Maxtor from sleeping (hard disk spindown is turned off in the system control panel of course). I tried both the cron job doing an "ls" as well as the "touch" method. I verified that the cron job is actually touching the file (if I delete it it does reappear). Any suggestions? This is VERY annoying and slows down my system considerably.

[ Reply to This | # ]
Authored by: Andrew McDonald on Jun 26, '03 05:31:58PM
What about ping?

   ping -i 300 > /Volumes/MyVolume/wake_up

Background it with an ampersand, or make it temporary by using the -c flag.

[ Reply to This | # ]

Authored by: tootired on Oct 18, '04 05:52:05PM

Hi !

I am using this one:

# crontab -l
*/10 * * * * date >/Volumes/Home/; /bin/sync

any comments ?


[ Reply to This | # ]
Use a cron job to prevent hard drive spindown
Authored by: gaberohmann on Jul 03, '07 08:28:34AM

The following hint worked for me on a Maxtor Personal Storage 230gb. I found the following post on Ask Metafilter, and had to alter it with "" to make it work on 10.4.9 So far it is definitely is working to keep the External Hard Drive busy. I used Cronnix to set up the crontab, but you could just as easily do it in the Terminal.

I made a small text file called stayalive.txt in the root of the External drive, (you'll have to change it to match your location- mine is called 'storage'), then it copies it to a new file called stayinalive.txt

What it does is touches the file, then copies it to a new file once a minute. Easily keeps Hard Drive spinning!


* * * * * root touch "/Volumes/storage/stayalive.txt"; cp "/Volumes/storage/stayalive.txt" "/Volumes/storage/stayinalive.txt"

I'm so happy this worked!! :)

[ Reply to This | # ]
Use a cron job to prevent hard drive spindown
Authored by: alaskinhuski on Jul 18, '08 03:30:21PM

I love the idea, but when I tried it, I found that after the first ls -la of my drive, the hard drive spins up, but for subsequent times it doesn't bother and just prints the same list. It must know that nothing has changed so there's no need to access the drive again, or something.

What's crazy is that my hard drive, a Maxtor OneTouch 4, spins down after as little as ONE MINUTE of inactivity.

So now I'm using a touch cron job like someone suggested,

*/1 * * * * touch -m /Volumes/"External HD"/Relentless

, but now I feel like this really really can't be good for the drive. Every minute I'm writing to the drive.

Does anyone know a Mac OS X command that would simply cue the drive to keep spinning?

Or is there some way to force it to look for a new file list?

Also, I've tried using cat to the /dev/null also, but again, after the first use, my drive doesn't bother spinning up and it just spews out the same cat as before unless I made some change on the drive between 'cat's

[ Reply to This | # ]
Use a cron job to prevent hard drive spindown
Authored by: agentbullvi on Feb 02, '10 07:13:25AM
I'm using this in my crontab and it works well.
*/5 08-19 * * 1-5 /bin/date > /Volumes/drive0/.anti-spindown
This performs a disk write every 5 minutes between the hours of 8am-7pm Monday through Friday I'm pretty happy with the solution.
Edited on Feb 02, '10 07:14:16AM by agentbullvi

[ Reply to This | # ]