Running matlab in the background Running matlab in the background shell shell

Running matlab in the background


Use nohup command on UNIX to prevent MATLAB stop when you logout.

nohup matlab -nodisplay -nosplash -r matlab_command > outfile.txt &

And don't forget to include exit; at the end of matlab_command script.

UPDATE:

Try this solution: Is it possible to run MATLAB in the background under UNIX?

There is an explanation here.


The real clean solution to your problem is to use GNU Screen.Then you will not loose your Matlab session and you can always get back into the Matlab prompt. Very helpful if somebody went wrong with your Matlab code and you need to debug a little.

Just fire up 'screen' (after you have the package installed, included in all major distributions). You will have a typical prompt, but inside a persistent, virtual terminal. Start your matlab as usual, omit any backgrounding. Then press CTRL+A, D (first CTRL+A, then d). You will be out of screen. You can logout. If you want to get back to your screen session, run screen -r. If you want, you can also directly start screen matlab [...] in the first place. It will have the effect that your virtual session is also dropped when matlab quits.


I am using this workaround, which provides a dummy standard in:

matlab -r matlab_command > outfile.txt < /dev/null &