![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1251212/image.png)
How to get pid of an external executable run in linux?
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I would like to run an exeternal executable in matlab in linux. I would like to get the pid of the process.
For example, I can run an external executable using
[status,cmdout] = system('.\myexecutable.exe > myoutput.txt &');
I would like to get the pid of .\myexecutable.exe > myoutput.txt &
I am open to running the executable using functions other than system as well. Please note that I am using MATLAB in Linux. Thank you.
0 个评论
回答(1 个)
Bhavana Sapparapu
2023-1-4
编辑:Stefanie Schwarz
2024-2-23
Hi Sravan,
I understand that you are trying to run an external executable/process on MATLAB and find its process ID from MATLAB itself on a Linux platform.
At present, there is no direct MATLAB command or function to obtain the PID of a process. But you can try the following workaround that utilizes the 'ps' shell command:
>> system('process name & ps')
Following is the screenshot of the example I have tried on my end:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1251212/image.png)
Also, there is third party command called the 'pslist' command for Linux platforms.
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 PID Controller Tuning 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!