Automatically restart Matlab after Microsoft forces restart
8 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(3 个)
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
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
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
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).
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.
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!