Automatically restart Matlab after Microsoft forces restart

5 views (last 30 days)
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

Answers (3)

John D'Errico
John D'Errico on 4 Jan 2017
Edited: John D'Errico on 4 Jan 2017
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 Comments
Star Strider
Star Strider on 5 Jan 2017
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 on 5 Jan 2017
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

Sign in to comment.


Guillaume
Guillaume on 3 Jan 2017
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 Comment
jlt199
jlt199 on 3 Jan 2017
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! :(

Sign in to comment.


Jan
Jan on 3 Jan 2017
Edited: Jan on 3 Jan 2017
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 Comments
jlt199
jlt199 on 4 Jan 2017
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 on 9 Jan 2017
Edited: Jan on 9 Jan 2017
"Your" license or your Matlab license? For the second: Yes. For the first: It depends on what you have signed with your license agreement. ;-)

Sign in to comment.

Categories

Find more on Install Products in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!