1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to? Wake up a sleeping drive

Discussion in 'Support' started by Avi Shmidman, Jun 19, 2012.

  1. Avi Shmidman

    Joined:
    Feb 23, 2012
    Messages:
    238
    Likes Received:
    3
    I have an external drive plugged in to my computer which goes to sleep after a certain period of non-activity. If I then access the drive, the drive starts to spin up, but it takes its time, paralyzing the calling application - whether TCC or Windows Explorer - for some 2-3 minutes.
    I'd like to know if there is a command I can send from the TCC command line which will effectively wake up the drive, but without freezing the command line while waiting for the response. Thus I'll be able to continue using the command window for other things, and after a few minutes I'll be able to get back to the drive and use it without delay.
     
  2. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,189
    Likes Received:
    11
    I would guess the answer to that is no. Most likely the delay is happening at the device driver level and there's not much you can do about that.

    Check the Windows Power settings and see if you have selected to turn off drives after a certain period of inactivity. That is the default Windows behavior.
    Or you might consider writing an app that periodically accesses the drive to keep it from going to sleep in the first place - kind of like a keep-alive.
    You could write a simple BTM file that gets invoked by the Task Scheduler.
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    How about
    Code:
    START D:\
    Let Explorer wait on the drive....
     
  4. Avi Shmidman

    Joined:
    Feb 23, 2012
    Messages:
    238
    Likes Received:
    3
    Hi guys,
    Thanks for the ideas.
    Scott - I understand your idea for a keep-alive, but the truth is that I kind of like the idea that the drive stops spinning when in non-use. It seems to me (correct me if I'm wrong) that this improves the odds of the drive surviving in case the power is cut. Over the last 15 years I've lost a number of external drives to power issues, including an Iomega Jaz drive that was destroyed when somebody tripped over the power cord. I'd imagine that the chances of survival are much higher if the drive has already spun down and the parts are no longer moving.
    Charles - I tried your idea, but I see now that things are not completely consistent. Specifically, when I tried it now, "start d:" executed immediately, and it was only after exploring two levels deep in the directory that the spin-up began. I guess the file system had cached a portion of the directory structure.
    Overall, I think that what might be most useful here would be to have the ability within TCC to break (ctrl-c) a waiting file operation even though it has not completed or reached the timeout value. This is something that I've raised before regarding "cd" and "dir" commands on ftp servers, which can also take a very long time to timeout. Here, too, it would be nice if Ctrl-C were an option, rather than having to wait for the whole spin-up (or timeout).
    In terms of implementation - I understand that right now TCC doesn't have the option of responding to a Ctrl-C keypress in these situations, because it is stuck waiting for a response from the file system. However, I'd suggest that this can be effectively solved by using a second thread to do the file system call. The first thread would wait either for Ctrl-C or for completion of the second thread. If Ctrl-C is hit before the second thread completes, TCC can continue as normal and receive further commands (in this case, the second thread will continue to wait until the file system's response or timeout, at which point it will simply discard the result and exit).
    What do y'all think about this proposal? If you think it makes sense, I'll add it to the uservoice forum.
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,949
    Likes Received:
    30
    2-3 minutes seems like a very long time to wait for an external hard drive to wake up.

    I suspect this could be done relatively easily with a plugin. [Avi, do you use my 4UTILS?] A command, say "WAKEUP <drive>", could return immediately after starting a thread that would attempt to access a specified drive. Are there any ideas on how to do this? A FindFirstFile() might be thwarted by cacheing. A CreateFile/WriteFile/FlushFileBuffers/DeleteFile ought to work (I do that on another system, with a scheduled task, to keep an ActiveDirectory share connected). Notification that the drive is ready would be awkward, especially if it were to come a long time later.
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,949
    Likes Received:
    30
    You could write a BTMfile that will wake the drive (probably plenty of ways to do that), say WAKEME.BTM <drive>, and make an alias, WAKE=START /INV WAKEME.BTM %1. Then give the command (for example) "WAKE d:".
     
  7. Stefano Piccardi

    Joined:
    May 31, 2008
    Messages:
    376
    Likes Received:
    2
    untested, how about
    Code:
    *del /q "%@unique[D:\]" &
    
     
  8. Avi Shmidman

    Joined:
    Feb 23, 2012
    Messages:
    238
    Likes Received:
    3
    Hi guys,
    Thanks for the suggestions!
    Stefano, your line worked perfectly to wake up my drive (and I was very pleased to discover this very useful and clever function called @unique!)
    Vince, I appreciate your ideas and your help in formulating the script.
    Vince, you also asked if I use 4UTILS. As of now I have not tried it, but I'll take a look at it. Is there something there that would be specifically helpful regarding the issue at hand?
    Also, Vince, you noted that 2-3 minutes is a long time for start up. I agree, but that's what I am seeing with my drive. It's a Seagate Freeagent drive, plugged into my firewire port.
     
  9. Stefano Piccardi

    Joined:
    May 31, 2008
    Messages:
    376
    Likes Received:
    2
    Avi, I'm glad my line works for you. Keep in mind that the line won't work in TCCLE - if you use TCCLE at all - because the trailing &, which stands for DETACH, isn't supported in TCCLE.
     
  10. Avi Shmidman

    Joined:
    Feb 23, 2012
    Messages:
    238
    Likes Received:
    3
    Hi Stefano,
    I only use the full version of TCC, but thanks for the tip. I do have friends here that use TCC/LE. Just one more reason to persuade them to upgrade.
    By the way, is the & essentially equivalent to the START command, or are there fundamental differences?
     
  11. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,949
    Likes Received:
    30
    Nice one, Stefano! Avi, read about DETACH too. I doubt there's anything in 4UTILS that will help with this.
     
  12. Stefano Piccardi

    Joined:
    May 31, 2008
    Messages:
    376
    Likes Received:
    2
    & is equivalent to DETACH, not START. Both START and DETACH start a program but there are fundamental differences. Grossly speaking, think of START as "foreground" (has own window), and of DETACH as "background" (has no own window). The help file can tell you much more.
     
  13. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,949
    Likes Received:
    30
    I wonder how much trouble you could get into using a thread instead of a new process. For example, a plugin THREAD command might be used thus: "THREAD *DEL /Q %@UNIQUE[d:\]". THREAD would create a thread and return immediately; the thread would use Command() to execute the specified command.
     
  14. Stefano Piccardi

    Joined:
    May 31, 2008
    Messages:
    376
    Likes Received:
    2
    Do I hear a thread library plugin ? :)
     
  15. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,949
    Likes Received:
    30
    No, but I'm playing with a THREAD command in 4UTILS. It basically works but I have no doubt one could make bad things happen with it. My only tests so far have been simple ones, as below. I can start overlapping instances of THREAD and do other simple things while the threads are running. Below, regardless of what I'm doing, when the times come, I hear the beeps.
    Code:
    p:\4utils\release> thread wait 30s ^& beep
     
    p:\4utils\release> thread wait 30s ^& beep
     
    p:\4utils\release> thread wait 30s ^& beep
     
    p:\4utils\release> echo foo
    foo
     
    p:\4utils\release> echo bar
    bar
     
    p:\4utils\release> dir /k /m *.txt
    2006-01-05  14:44          4,658  4utils.txt
    2009-10-30  20:28          3,750  avetemp.txt
    2010-07-30  14:23        341,209  capture.txt
    2010-05-30  13:55          1,308  exports.txt
    2010-05-30  14:05          1,067  exports10.txt
    2010-06-10  15:33              3  nolastcrlf.txt
    2008-05-10  12:33              34  tfile.txt
    2009-09-28  12:58              34  tfile2.txt
    2009-09-28  13:16              70  utfile.txt
     
    p:\4utils\release> now, while I'm typing, I hear the three beeps
     

Share This Page