MATLAB Answers

Q Liao

How to initiate a linux (shell) command from matlab but not wait for the output?

Asked by Q Liao
on 12 Jul 2013
Latest activity Commented on by esmail
on 17 Feb 2015

I know I can use the function unix (or system), but it has to wait the script to return. The script actually will run for a long time. I prefer matlab function to return immediately after calling the shell script. Is it possible?

Thanks a lot in advance!


1 Answer

Answer by Ken Atwell
on 13 Jul 2013
 Accepted answer

If you end the command line with an ampersand, system should return immediately

 system('some-long-running-command &');

Of course, you won't be able to capture the output of the command.


Q Liao
on 13 Jul 2013

Thanks a lot! It works!!

on 17 Feb 2015

Hi. My problem is that I'm running multiple files with & in the background and am using system('wait') for all of them to complete. However, system('wait') is not working. I'd appreciate your response.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!