Reading:Nohup, Comsol and Matlab

Nohup, Comsol and Matlab

When you want to use a Matlab script to perform simulations with Comsol,  a remote server is often used. This post is a quick note to help you creating matlab scripts that would be run on a remote server.

The strategy is the following. We will use the nohup command to let the server do the simulations while we will turn off our computer. Without the nohup, turning off your computer would result in breaking the ssh connexion, and thus, the matlab/comsol processes that were running. Another solution could have been the use of the command screen.

First you have to be sure that you Matlab script won’t output graphical windows which would need X to be printed. If such windows appear during your calculation, then the script would have to stop. In order to prevent java windows to be created, add this at the beginning of your Matlab script :

  • flreport(‘off’)

Second, you have to force your script to close the matlab process after the simulation. So you have to add this at the end of your script :

  • exit

Now, you just have to create a directory for your simulation of the day, upload all your script’s files, and launch the following command via a terminal when you’ll be located in your simulation’s folder :

  • nohup comsol matlab -ml -nodesktop -ml -nosplash -mlr “Script_matlab” &


Note : here we assumed that the script was called _Scriptmatlab.m. Be carefull, and don’t forget to remove the extension “.m” when you use nohup.