Thread Subject: running matlab in background

Subject: running matlab in background

From: Alex

Date: 28 May, 2009 19:26:02

Message: 1 of 9

I am running matlab over the network on a linux server. If I say:

matlab -r script

it runs fine, but brings up the matlab window.

But if I say

matlab -r script &

in order to run it in the background, it stops running immediately. Here is what I get in the terminal window:

matlab -r bursttriggers &
[1] 6223
[abarrie@owain scripts]$ which: no shopt in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/abarrie/bin:/home/abarrie/fpi/scripts:/home/abarrie/fpi/PRV_May2007/DWT:/home/abarrie/fpi/PRV_May2007/BPE)
Warning: No display specified. You will not be able to display graphics on the screen.

[abarrie@owain scripts]$

[1]+ Stopped matlab -r bursttriggers

Any suggestions on why it is quitting? I am not sure what that shopt thing is....

Subject: running matlab in background

From: checker i

Date: 28 May, 2009 19:35:02

Message: 2 of 9

"Alex" <abarrie@meicompany.com> wrote in message <gvmog9$ode$1@fred.mathworks.com>...
> I am running matlab over the network on a linux server. If I say:
>
> matlab -r script
>
> it runs fine, but brings up the matlab window.
>
> But if I say
>
> matlab -r script &
>
> in order to run it in the background, it stops running immediately. Here is what I get in the terminal window:
>
> matlab -r bursttriggers &
> [1] 6223
> [abarrie@owain scripts]$ which: no shopt in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/abarrie/bin:/home/abarrie/fpi/scripts:/home/abarrie/fpi/PRV_May2007/DWT:/home/abarrie/fpi/PRV_May2007/BPE)
> Warning: No display specified. You will not be able to display graphics on the screen.
>
> [abarrie@owain scripts]$
>
> [1]+ Stopped matlab -r bursttriggers
>
> Any suggestions on why it is quitting? I am not sure what that shopt thing is....


I am not sure of the linux O.S.. But similar implementation question has been discussed before. I am not sure if this link totally help you though!
http://www.mathworks.com/matlabcentral/newsreader/view_thread/151561

Subject: running matlab in background

From: Alex

Date: 29 May, 2009 18:03:01

Message: 3 of 9

most of the other posts just talk about using the -r option to run a script, which i am doing. the problem is that when i run it as a background job it no longer works.


"checker i" <checker.im@gmail.com> wrote in message <gvmp16$ov$1@fred.mathworks.com>...
> "Alex" <abarrie@meicompany.com> wrote in message <gvmog9$ode$1@fred.mathworks.com>...
> > I am running matlab over the network on a linux server. If I say:
> >
> > matlab -r script
> >
> > it runs fine, but brings up the matlab window.
> >
> > But if I say
> >
> > matlab -r script &
> >
> > in order to run it in the background, it stops running immediately. Here is what I get in the terminal window:
> >
> > matlab -r bursttriggers &
> > [1] 6223
> > [abarrie@owain scripts]$ which: no shopt in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/abarrie/bin:/home/abarrie/fpi/scripts:/home/abarrie/fpi/PRV_May2007/DWT:/home/abarrie/fpi/PRV_May2007/BPE)
> > Warning: No display specified. You will not be able to display graphics on the screen.
> >
> > [abarrie@owain scripts]$
> >
> > [1]+ Stopped matlab -r bursttriggers
> >
> > Any suggestions on why it is quitting? I am not sure what that shopt thing is....
>
>
> I am not sure of the linux O.S.. But similar implementation question has been discussed before. I am not sure if this link totally help you though!
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/151561

Subject: running matlab in background

From: John

Date: 29 May, 2009 18:22:02

Message: 4 of 9

Try matlab -nodesktop -r script > output.txt &

"Alex" <abarrie@meicompany.com> wrote in message <gvmog9$ode$1@fred.mathworks.com>...
> I am running matlab over the network on a linux server. If I say:
>
> matlab -r script
>
> it runs fine, but brings up the matlab window.
>
> But if I say
>
> matlab -r script &
>
> in order to run it in the background, it stops running immediately. Here is what I get in the terminal window:
>
> matlab -r bursttriggers &
> [1] 6223
> [abarrie@owain scripts]$ which: no shopt in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/abarrie/bin:/home/abarrie/fpi/scripts:/home/abarrie/fpi/PRV_May2007/DWT:/home/abarrie/fpi/PRV_May2007/BPE)
> Warning: No display specified. You will not be able to display graphics on the screen.
>
> [abarrie@owain scripts]$
>
> [1]+ Stopped matlab -r bursttriggers
>
> Any suggestions on why it is quitting? I am not sure what that shopt thing is....

Subject: running matlab in background

From: Alex

Date: 29 May, 2009 19:16:01

Message: 5 of 9

I tried that and I also tried using the -logfile option. In both cases the outfile was empty so it looks like it is not even getting to the point of trying to run something.


"John" <sjohn@cnbc.cmu.edu> wrote in message <gvp94a$cfa$1@fred.mathworks.com>...
> Try matlab -nodesktop -r script > output.txt &
>
> "Alex" <abarrie@meicompany.com> wrote in message <gvmog9$ode$1@fred.mathworks.com>...
> > I am running matlab over the network on a linux server. If I say:
> >
> > matlab -r script
> >
> > it runs fine, but brings up the matlab window.
> >
> > But if I say
> >
> > matlab -r script &
> >
> > in order to run it in the background, it stops running immediately. Here is what I get in the terminal window:
> >
> > matlab -r bursttriggers &
> > [1] 6223
> > [abarrie@owain scripts]$ which: no shopt in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/abarrie/bin:/home/abarrie/fpi/scripts:/home/abarrie/fpi/PRV_May2007/DWT:/home/abarrie/fpi/PRV_May2007/BPE)
> > Warning: No display specified. You will not be able to display graphics on the screen.
> >
> > [abarrie@owain scripts]$
> >
> > [1]+ Stopped matlab -r bursttriggers
> >
> > Any suggestions on why it is quitting? I am not sure what that shopt thing is....

Subject: running matlab in background

From: John

Date: 29 May, 2009 19:41:01

Message: 6 of 9

Is it still producing the display error when you try with the -nodesktop option ?Can you paste here the command you used and the error generated ?.

Subject: running matlab in background

From: Alex

Date: 29 May, 2009 19:54:02

Message: 7 of 9

Here is the input and output. One other item of note: the process does not actually end, but looks like it crashes. if I kill the process using just kill it does not die. I have to give it a kill -9 to actually get rid of it.

$ matlab -r bursttriggers -nodesktop -logfile log &
[1] 10417
$ which: no shopt in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/abarrie/bin:/home/abarrie/fpi/scripts:/home/abarrie/fpi/PRV_May2007/DWT:/home/abarrie/fpi/PRV_May2007/BPE)
Warning: No display specified. You will not be able to display graphics on the screen.


[1]+ Stopped matlab -r bursttriggers -nodesktop -logfile log
$ cat log
$
$ ps
  PID TTY TIME CMD
 9620 pts/2 00:00:00 bash
10417 pts/2 00:00:00 MATLAB
10505 pts/2 00:00:00 ps
$ kill 10417
$ ps
  PID TTY TIME CMD
 9620 pts/2 00:00:00 bash
10417 pts/2 00:00:00 MATLAB
10506 pts/2 00:00:00 ps
$ kill -9 10417
$ ps
  PID TTY TIME CMD
 9620 pts/2 00:00:00 bash
10507 pts/2 00:00:00 ps
[1]+ Killed matlab -r bursttriggers -nodesktop -logfile log
$



"John" <sjohn@cnbc.cmu.edu> wrote in message <gvpdod$9g1$1@fred.mathworks.com>...
> Is it still producing the display error when you try with the -nodesktop option ?Can you paste here the command you used and the error generated ?.

Subject: running matlab in background

From: Andreas

Date: 4 Sep, 2009 20:26:01

Message: 8 of 9

"Alex" <abarrie@meicompany.com> wrote in message <gvmog9$ode$1@fred.mathworks.com>...
> I am running matlab over the network on a linux server. If I say:
>
> matlab -r script
>
> it runs fine, but brings up the matlab window.
>
> But if I say
>
> matlab -r script &
>
> in order to run it in the background, it stops running immediately. Here is what I get in the terminal window:
>
> matlab -r bursttriggers &
> [1] 6223
> [abarrie@owain scripts]$ which: no shopt in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/abarrie/bin:/home/abarrie/fpi/scripts:/home/abarrie/fpi/PRV_May2007/DWT:/home/abarrie/fpi/PRV_May2007/BPE)
> Warning: No display specified. You will not be able to display graphics on the screen.
>
> [abarrie@owain scripts]$
>
> [1]+ Stopped matlab -r bursttriggers
>
> Any suggestions on why it is quitting? I am not sure what that shopt thing is....

Came across this trouble today, which is annoying that it stops a script. My workaround is instead of calling:

matlab -r script &

do:

echo "matlab -r script" | sh &

this will only throw the warning and not pause execution

Subject: running matlab in background

From: Alex

Date: 9 Sep, 2009 17:28:19

Message: 9 of 9

"Andreas " <afe405@hotmail.com> wrote in message <h7rt4p$l54$1@fred.mathworks.com>...
> "Alex" <abarrie@meicompany.com> wrote in message <gvmog9$ode$1@fred.mathworks.com>...
> > I am running matlab over the network on a linux server. If I say:
> >
> > matlab -r script
> >
> > it runs fine, but brings up the matlab window.
> >
> > But if I say
> >
> > matlab -r script &
> >
> > in order to run it in the background, it stops running immediately. Here is what I get in the terminal window:
> >
> > matlab -r bursttriggers &
> > [1] 6223
> > [abarrie@owain scripts]$ which: no shopt in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/abarrie/bin:/home/abarrie/fpi/scripts:/home/abarrie/fpi/PRV_May2007/DWT:/home/abarrie/fpi/PRV_May2007/BPE)
> > Warning: No display specified. You will not be able to display graphics on the screen.
> >
> > [abarrie@owain scripts]$
> >
> > [1]+ Stopped matlab -r bursttriggers
> >
> > Any suggestions on why it is quitting? I am not sure what that shopt thing is....
>
> Came across this trouble today, which is annoying that it stops a script. My workaround is instead of calling:
>
> matlab -r script &
>
> do:
>
> echo "matlab -r script" | sh &
>
> this will only throw the warning and not pause execution

I actually started running it through screen and it seems to work OK. thanks for the tip though!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
crash Alex 29 May, 2009 15:59:04
nodesktop John 29 May, 2009 14:24:11
rssFeed for this Thread

Contact us at files@mathworks.com