Launching-matlab-in-background-correctly-in-linux
You want to launch Matlab for a very long script and then disconnect your remote terminal, and when back, not finding bad surprise.
Suppose your script myeigenvalues.m
is:
- Create a helper script
helper_myegeinvalues.m
that launchesmyeigenvalues.m
script but surrounded by a try-catch block like this:
The try-catch block is needed to avoid leaving Matlab open in idle status if an error occurred once launched as background process.
- Create another helper bash-script file
helper_myegeinvalues.sh
that runs the scripthelper_myegeinvalues.m
- Make the
helper_myegeinvalues.sh
file executable by issuing
- Run the
helper_myegeinvalues.sh
as a nohup command and collect all the output into the filestdout.txt
- You can now leave the process run and stay happy.