Close my terminal but keep matlab running on a remote Ubuntu
显示 更早的评论
hi Folks:
I don't have much experience running Matlab remotely, so please forgive me if you think my question is dumb.
I am running Matlab on a remote Ubuntu from my laptop. My Matlab program takes hours, or even days to run. So the best way is to let it run on the remote Ubuntu even if I logout my connection with it.
I was told screen command can do that. So here is what I did:
1. Connect to the remote Ubuntu using butty, initiate a new screen session, and start Matlab.
2. Let the Matlab scrip run. (when Matlab script is running, its interface is shown on my laptop)
3. Detach, and then logout the screen session.
4. Close butty (of course, the Matlab windows on my laptop were also gone)
5. Reconnect to the remote Ubuntu, and re-attach the screen session.
But, no Matlab was running!
So, how do I run my Matlab script on that remote Ubuntu with my connection to that server is closed?
Thanks a lot. Any suggestion is appreciated.
采纳的回答
更多回答(5 个)
Daniel Shub
2012-3-5
1 个投票
I use screen. I am pretty sure this is exactly what it was designed for.
Honglei Chen
2012-3-5
0 个投票
I normally use VNC for such purpose. I started a VNC server on the remote machine and then connect to it using a VNC client. Once I'm done starting the program, I just close the VNC client. I connect again later to check the results.
Nick Tsui
2012-3-5
0 个投票
2 个评论
Jason Ross
2012-3-5
FWIW, if you used the VNC method you could have the figures back.
Robin tournemenne
2018-2-27
On high performance computing platforms you usually don't have the rights to use VNC but only ssh.
PureLearningCoding
2017-4-4
0 个投票
I am using tmux and had similar problem. If I stop the X-ming server, the problem is gone.
Subhradip Paul
2020-5-13
0 个投票
you can use:
nohup matlab -nosplash -nodisplay -nodesktop -r 'try; scriptname without .m; catch; save code_err; end; quit'>output.log &
you have to save the workspace though at the end of the script.
Also if there is an error, it will save data till there on code_err
you can check the output on output.log using less or vim.
4 个评论
Md Mahbub E Noor
2020-5-29
编辑:Md Mahbub E Noor
2020-5-29
So where should i put that command? In remote terminal or inside matlab code?
Subhradip Paul
2020-6-2
you have to navigate to the folder where your script is.
say your folder is mymatlab in home, you go to that folder using cd ~/mymatlab, and then if the script name is test.m the command should be:
nohup matlab -nosplash -nodisplay -nodesktop -r 'try; test; catch; save code_err; end; quit'>output.log &
It should not be in the matlab code.
Make sure that all the supporting scripts are in the path.
Hope that helps.
mathieu perton
2021-3-18
It is wonderful ! Thanks a lot.
David Sterling
2022-8-23
As mentioned above, If you are using tmux (presumably something simillar happens with screen), you can run matlab interactively in the terminal with :
matlab -nodisplay -nodesktop
You can then disconnect from your tmux session (whether on purpose or because you connection to the remote machine drops) ; when you re-attach to your tmux session in the future Matlab (and any other processes running in that session) will still be running.
I use this method to keep my Matlab sessions alive on a remote machine running Ubuntu 20.04 -- works great
类别
在 帮助中心 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!