PHD Discussions Logo

Ask, Learn and Accelerate in your PhD Research

Question Icon Post Your Answer

Question Icon

7 years ago in Matlab By Rajshree Tamang

Run MATLAB in background

Hello everyone, I use UNIX operating system and I have successfully installed MATLAB in my system. I want to know if I can run MATLAB in the background in UNIX system. If yes how do I do it? Can someone guide me on this? It would be of great help.

All Answers (3 Answers In All)

By Tarushi Yadav Answered 7 years ago

Use GNU screen. You will not lose your session and can easily get back to MATLAB prompt.

By Sriya Rawat Answered 7 years ago

Simply use nohup command on UNIX to prevent MATLAB stop when you log out.
nohup matlab -nodisplay -nosplash -r matlab_command > outfile.txt &
And don’t forget to include exit; at the end of matlab_command script.

By Vipin Kumar Answered 7 years ago

Hi Rajshree! You can definitely run MATLAB in the background in UNIX operating system. The nohup command and unsetting the display will allow you to run MATLAB in the background successfully even when you log out. Just try the following:
set OLDDISPLAY=$DISPLAY
unsetenv DISPLAY
nohup matlab fileout &
setenv DISPLAY $OLDDISPLAY
where filein is the M-file you want to run and fileout is the file you want the output to go to. To set this up as a C shell script, write a file called matbat as:
#!/bin/csh set OLDDISPLAY=$DISPLAY
unsetenv DISPLAY nohup matlab $2 &
setenv DISPLAY $OLDDISPLAY
To run this file, issue the command as:
matbat infile outfile
It did work in my system.

Your Answer