How to use nohup feature in MATLAB with Linux-based OS

50 ビュー (過去 30 日間)
Sumit Kumar Das
Sumit Kumar Das 2023 年 7 月 20 日
コメント済み: Walter Roberson 2024 年 1 月 17 日
I have been curious to understand the usage of the nohup feature in MATLAB with a Linux-based OS. While I have attempted to find answers to my questions on the internet, the instructions provided by users can be quite confusing to follow. It would be greatly appreciated if someone could assist me in resolving the following queries.
  1. How to execute a MATLAB script file with nohup feature?
  2. How to know if the MATLAB script is being executed on nohup command?
  3. How to stop executing the MATLAB script midway, in case you start it by mistake?
Indeed, the queries and answers provided in this thread form a comprehensive guide for MATLAB users.

採用された回答

Ashutosh
Ashutosh 2023 年 8 月 22 日
Following are the responses to the queries which has been asked:
  • 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('your_file.m'); exit" > output.log 2>&1 &
Replace 'your_file.m’ with the actual name of your file.
  • To check whether the MATLAB script is being executed with the "nohup" command, use the "ps" command to list the running processes. Open a terminal and enter the following command:
ps aux | grep matlab
This will display the list of processes that include term matlab.
  • To stop the execution of the script use "kill" command to stop the execution of the process with the process ID (PID) of it which is known by the previous command.
kill PID
  4 件のコメント
Sumit Kumar Das
Sumit Kumar Das 2024 年 1 月 17 日
The steps provided by @Ashutosh work well on my workstation. If there are any issues with executing MATLAB, it could be due to directory problems. Therefore, I would recommend running the following line of code.
nohup <matlab executable location (e.g., /usr/local/MATLAB/R2022b/bin/matlab)> -nosplash -nodisplay -nodesktop -r 'try; <matlab script file name without the extension>; catch; end; quit' > <log file name if you want to save command window>.log &
Note:
  1. First, locate the MATLAB executable on your system and specify the correct executable directory in the above code.
  2. The content inside < > is user-defined, so care should be taken while writing. However, note that the > sign after quit' is an integral part of the code.
  3. Choosing a suitable file name is advisable, such as writing a name without spaces and connecting the words with a special character. For example, "StressAnalysis.m" and "Stress_Analysis.m" are preferable choices over "Stress Analysis.m."
  4. The abovementioned line of code is intended solely for activating the nohup feature in MATLAB.
Walter Roberson
Walter Roberson 2024 年 1 月 17 日
The
[1] 69286
indicates that process 69286 is waiting on I/O channel #1 (stdout).
You would get that message if you failed to redirect stdout.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by