MATLAB: Does PBS not keep track of system calls made from MATLAB Distributed Computing Engine

MATLAB Parallel ServerParallel Computing Toolbox

I am using PBS as my scheduler. In my MATLAB file I use the SYSTEM command, UNIX command, or the ! (bang) operator to execute an operating system command.
The PBS application MOM does not seem to keep track of any processes which are spawned off from any system command executed by MATLAB.

Best Answer

On UNIX operating systems (Linux, Solaris, and Mac), all system calls are made by forking the matlab_helper process which is forked off from MATLAB during startup. The matlab_helper process has a different session ID. All subsequent system calls have the same session ID as matlab_helper. This can be seen below in the output of the ps command "ps -e -o pid,ppid,sess,tname,cmd", where the command "ls -R" was shelled out from MATLAB.
PID PPID SESS TTY CMD
9967 9874 9874 pts/0 /mathworks/devel/bat/archive/R2006b/ship/unix/dist/bin/glnxa64/MATLAB
10057 9967 10057 pts/1 /mathworks/devel/bat/archive/R2006b/ship/unix/dist/bin/glnxa64/matlab_helper /dev/pts/1 yes
10453 10057 10057 pts/1 -bin/tcsh -c ls -R
10460 10453 10057 pts/1 ls -R
Note: above output has been edited for brevity
One way for PBS to keep track of the processes is to use the pbs_attach command. Please refer to the PBS documentation or support for more information on this command. Therefore, if the pbs_attach command is pre-pended to any operating system commands, those processes will be monitored by PBS. For example, if you are trying to execute a program called "foo" and pbs_attach is located at "/usr/pbs/bin/pbs_attach", then you could execute the following system command:
prefix = '/usr/pbs/bin/pbs_attach -j $PBS_JOBID ';
system([prefix 'foo']);
Note: by using the -j option, the process will be attached to the job ID specified if more than one job is running on the computer.
Note: MathWorks does not provide support for using 3rd party products. The above solution has not been tested and is not guarenteed to work in future releases of MATLAB.