Borrar filtros
Borrar filtros

How to run matlab code in the server background?

75 visualizaciones (últimos 30 días)
Jingyu Liu
Jingyu Liu el 27 de Feb. de 2022
Editada: Yigithan Mehmet Kose el 16 de En. de 2024
Take the following matlab code for an example. How to run it in the server background? I tried nohup test.m & but failed.
% test.m
A = [
1,2,3;
4,5,6;
7,8,9
];
b = [1;1;1];
x = A*b;
save x;
Any suggestion is appreciated. Thanks!

Respuestas (1)

Vaibhav
Vaibhav el 4 de Oct. de 2023
Hi Jingyu Liu,
I understand that you want to run the MATLAB code in the background. One workaround is to utilize MATLAB in command-line mode.
Here are the steps to access MATLAB in this mode:
  • Commence MATLAB in command-line mode by entering the following command in the terminal:
matlab -nodesktop
  • This initiates MATLAB without the graphical user interface (GUI).
  • With MATLAB running in command-line mode, you can execute your MATLAB code by typing commands or running a MATLAB script or function.To run a script, such as "test.m," simply enter the script's name and press enter. It is possible to access multiple "MATLAB command windows" concurrently.
To Execute a MATLAB script with "nohup" feature, first, open a terminal on your Linux machine. second, navigate to the directory where MATLAB script file is located and execute the below command in the terminal:
nohup matlab -nodisplay -nosplash -r "run('test.m'); exit" > output.log 2>&1 &
You can refer to below blog to know more about '-nodesktop' feature:
You can refer to below MATLAB answer to know more about “nohup” feature:
Hope this helps!
Regards,
Vaibhav
  2 comentarios
Neda
Neda el 11 de Dic. de 2023
I have used "nohup matlab" with different suggested ways that I found in the internet, but I get this error all the time:
nohup: matlab: No such file or directory
while both matlab and nohup are accessible.
Yigithan Mehmet Kose
Yigithan Mehmet Kose el 16 de En. de 2024
Editada: Yigithan Mehmet Kose el 16 de En. de 2024
Hello, when I run this, I get the following message:
[1] 69286
What does that mean?

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by