필터 지우기
필터 지우기

Automatically restart Matlab after Microsoft forces restart

조회 수: 6 (최근 30일)
jlt199
jlt199 2017년 1월 3일
편집: Jan 2017년 1월 9일
Good morning and happy new year everyone.
I've just got back from a three week break over Christmas. I left a simulation running hoping it would be finished by today. However, on day three of my vacation, despite my best efforts to prevent it, Microsoft forced a restart and update installation. I am not impressed!
Is there a way to automatically restart Matlab and run a script file or function after such an occurrence?
My script file has several blocks, ideally I would like to start from the current block. Is this a possibility?
Many thanks

답변 (3개)

John D'Errico
John D'Errico 2017년 1월 4일
편집: John D'Errico 2017년 1월 4일
That you are not impressed is not relevant to MATLAB, but a problem with your OS. It decided to restart, and thereby blew you out of the water. MATLAB was offered no choice in the matter.
One way to resolve this on a long simulation is to periodically save results to a file so if things die, you can at least restart from that point.
  댓글 수: 4
Star Strider
Star Strider 2017년 1월 5일
When I used this approach, I saved the necessary intermediate variable values to ‘.mat’ files. I was writing one file with the interim simulation results, and a separate file (that I overwrote at each iteration) with the counters and all the intermediate variable values that would allow me to restart from an interruption.
I had to restart the computer and MATLAB manually (since the interruptions were usually due to thunderstorms), but I didn’t have to restart the simulation from the beginning.
Guillaume
Guillaume 2017년 1월 5일
Somethink like:
function StartSimulation(initcond1, initcond2, initcond3, ...)
currentstate.x = initcond1;
currentstate.a = initcond2;
currentstate.b = initcond3;
DoSimulation(currentsate);
end
function ResumeSimulation()
currentstate = load('simulationstate.mat');
DoSimulation(currentstate);
end
function DoSimulation(currentstate)
%the currentstate structure contains all variable necessary to perform one pass of the simulation
%if for some reason the simulation stops, the mat file contains the state of the simulation at the end of the last pass of the simulation.
while ~finished
currentstate.x = f1(currentstate.x);
[currentstate.a, currentstate.b] = f2(currentstate.a, currentstate.b);
%...
%at the end of the current processing pass, save everything in one go
save('simulationstate.mat', '-struct', 'currentstate');
end
end

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


Guillaume
Guillaume 2017년 1월 3일
Well, you can always add a matlab shortcut to the windows startup folder, then configure matlab to launch your script in its startup.m. As for resuming your script at a given location, it is only possible if you design it that way, for example, by writing its current progress in an m file and reading that progress when it starts.
But really, the best course of action is to truly disable automatic restarts (via group policy or registry).
  댓글 수: 1
jlt199
jlt199 2017년 1월 3일
Thanks, I thought I had disabled the updates through the group policy. It worked for a few months but Microsoft found a way to override! :(

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


Jan
Jan 2017년 1월 3일
편집: Jan 2017년 1월 3일
Neither this (admin privileges required)
system('sc stop wuauserv')
system('sc config wuauserv start=disabled')
nor disabling the scheduled task for the restarting:
system('schtasks /change /tn \Microsoft\Windows\UpdateOrchestrator\Reboot /DISABLE')
works perfectly. E.g. the later is re-enabled automatically once a day.
If you run Windows 10 you have accepted the license agreement:
6. Updates. The software periodically checks for system and app updates,
and downloads and installs them for you. You may obtain updates only from
Microsoft or authorized sources, and Microsoft may need to update your
system to provide you with those updates. By accepting this agreement, you
agree to receive these types of automatic updates without any additional
notice.
This means, that disabling the restart conflicts with the license conditions. Sigh.
If you require a system, which is guaranteed to not reboot automatically, install Matlab on Linux.
  댓글 수: 2
jlt199
jlt199 2017년 1월 4일
Doh! Looks like they have us over a barrel :(
I wonder if I can convince my company to let me run Linux. Would my current licence work on Linux?
Thanks
Jan
Jan 2017년 1월 9일
편집: Jan 2017년 1월 9일
"Your" license or your Matlab license? For the second: Yes. For the first: It depends on what you have signed with your license agreement. ;-)

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

카테고리

Help CenterFile Exchange에서 Install Products에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by