Prevent Mac from Falling Asleep While Running MATLAB Code

조회 수: 18 (최근 30일)
Miles
Miles 2015년 10월 12일
댓글: Walter Roberson 2017년 2월 11일
I'm looking to run a MATLAB script overnight that takes hours to run, but the problem is that my laptop falls asleep during that timeframe. I would like to add a line to the top of my script to tell my computer to disable sleep mode and then a line at the bottom of my script to enable sleep mode so that my computer isn't awake all night. I thought it might work to add system('caffeinate') at the top and system('killall caffeinate') at the bottom, but it gets hung up on the first command and doesn't run my code. Does anybody have a solution for this? I'm currently running MATLAB R2015a on OS X 10.10.5. Thanks for the help!

답변 (2개)

ptorab
ptorab 2017년 2월 11일
This is really a MATLAB OS X bug; MATLAB needs to send frequent PM assertions to OS X while it is running to prevent it from going sleep. Apple seems to have changed the logic of going to sleep to something that no longer depends on CPU or disk activity, but explicit power assertions from applications.
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 2월 11일
Hmmmm. There is not much hope that it would send power assertions while it is calling into MKL or LINPACK or BLAS to do extensive computations.

댓글을 달려면 로그인하십시오.


Kelly Kearney
Kelly Kearney 2015년 10월 12일
I've never used caffeinate, so I'm not entirely sure how the command works (though it looks like a good one to know, so thanks for the reference!). However, it looks like calling it without any inputs causes it to wait for a response, which is why Matlab never moves on to the next command. Perhaps try running it in the background?
system('caffeinate &');
  댓글 수: 1
Miles
Miles 2015년 10월 12일
Thanks for the quick response, that appears to make caffeinate work. Based on the documentation of caffeinate here, which arguments should I pass through to make sure my code doesn't stop? Would
system('caffeinate -dims &');
be the best implementation of this code?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by