Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Stop windows sleeping while matlab running

1,071 views
Skip to first unread message

caswell barry

unread,
Mar 31, 2010, 9:58:04 AM3/31/10
to
Hello,

So this should be pretty simple but I can't figure out how. I'm running a set of data analysis functions (basically a lot of parfor loops) that take about four hours to finish. Unfortunately during that time windows goes to sleep and the whole thing breaks. I don't really want to turn of sleep in Windows as I quite like the fact that under ordinary circumstances my machine sleeps after an hour. So what I want to know is if there is anyway to tell matlab to keep windows awake?

Thanks!

us

unread,
Mar 31, 2010, 10:07:05 AM3/31/10
to
"caswell barry" <caswel...@not-hotmail.com> wrote in message <hovkdc$c6u$1...@fred.mathworks.com>...

> Hello,
>
> So this should be pretty simple but I can't figure out how. I'm running a set of data analysis functions (basically a lot of parfor loops) that take about four hours to finish. Unfortunately during that time windows goes to sleep and the whole thing breaks. I don't really want to turn of sleep in Windows as I quite like the fact that under ordinary circumstances my machine sleeps after an hour. So what I want to know is if there is anyway to tell matlab to keep windows awake?
>
> Thanks!

well... sort of a conundrum, isn't it...
why not, for instance, extend the sleep-timer(?)...

us

caswell barry

unread,
Mar 31, 2010, 11:01:21 AM3/31/10
to

>
> well... sort of a conundrum, isn't it...
> why not, for instance, extend the sleep-timer(?)...
>
> us

Thanks for that suggestion. I don't really want to do that though as it would imply that my sleep times would have to be longer than the longest analysis I might run. Because my analyses take some time (potentially >12 hours) I might as well turn off the sleep timer.

Jan Simon

unread,
Mar 31, 2010, 11:52:05 AM3/31/10
to
Dear Caswell!

> > why not, for instance, extend the sleep-timer(?)...
>

> Thanks for that suggestion. I don't really want to do that though as it would imply that my sleep times would have to be longer than the longest analysis I might run. Because my analyses take some time (potentially >12 hours) I might as well turn off the sleep timer.

Usually the sleep time works as an idle timer: the timer starts, when the system load is small only. A computer falling to sleep during a high system load is obviously not a practical idea!

My WindowsXP, MacOS-9 and OS-X, Windows2000 and 95 systems do (did) not fall asleep during calculations. Is your Matlab running on a laptop with a machine specific power management tool?

Kind regards, Jan

Jan Simon

unread,
Mar 31, 2010, 12:28:21 PM3/31/10
to
Dear Caswell!

> Unfortunately during that time windows goes to sleep and the whole thing breaks.

Another idea: Are you allowed to change the power scheme without admin privilegs? Perhaps this must be enabled by an admin in the group policies.

Then you can disable the sleep timer from Matlab temporarily:
!powercfg /S "Disable shut-off Timers"
<your program>
!powercfg /S Desktop

Perhaps your power schemes have different names. Use this to show the scheme names:
!powercfg /L

See also:
http://support.microsoft.com/kb/324347

Good luck, Jan

caswell barry

unread,
Apr 28, 2010, 6:02:20 PM4/28/10
to
"Jan Simon" <matlab.T...@nMINUSsimon.de> wrote in message <hovr35$65b$1...@fred.mathworks.com>...

Hi,

Yes you would think that the sleep timer shouldn't kick in if the machine is doing something (my windows media pc, for example, doesn't turn off if it's recording or if I'm watching tv). However, in this case it seems that matlab doesn't keep the machine awake (I'm running matlab 2009a on windows 7 - it's a desktop with the normal windows power management).

caswell barry

unread,
Apr 28, 2010, 6:03:04 PM4/28/10
to
"Jan Simon" <matlab.T...@nMINUSsimon.de> wrote in message <hovr35$65b$1...@fred.mathworks.com>...

Hi,

caswell barry

unread,
Apr 28, 2010, 6:05:19 PM4/28/10
to
"Jan Simon" <matlab.T...@nMINUSsimon.de> wrote in message <hovt75$a9a$1...@fred.mathworks.com>...

Hi again. Yes this is what I ended up doing. I created a copy of my current power profile but with time to sleep set to infinity. I then found how to set a short cut on the desktop so that I can change between profiles with a single click (which is handy and means I'm more likely to remember to change back). Annoyingly I can't now remember how I did it - something like the shortcut uses the unique id that each power profile is recognised by.

Alvaro Duran Martinez

unread,
Sep 22, 2015, 3:22:08 AM9/22/15
to
I use the following commands at the begining and at the end of my script:

At the begining:

% Inhibit computer from going to sleep

system('powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c');

At the end:

% Allow computer to go to sleep

system('powercfg -setactive 381b4222-f694-41f0-9685-ff5bb260df2e');

The GUID used in each case is different on each computer. It can be queried by typing 'powercfg -list' on a command line window. There is a GUID for each energy mode, just choose the ones that allow or prevent the computer from going to sleep mode.

Alvaro Duran Martinez

unread,
Sep 22, 2015, 3:23:08 AM9/22/15
to
0 new messages