Issue
I use the nohup command to run my matlab program on a remote machine. Since I have to run the same program by changing some input parameters I decided to try to utilize the parallel computing toolbox functions. I have the following matlab script, say datafile.m:
% This is a matlab script titled datefile.m
a_array = [0;1;2;3];
jm = findResource('scheduler', 'Configuration', 'local');
job_ss = createJob(jm, 'Name', 'unsteady_slab_porous');
paths = {blah blah}
set(job_ss, 'PathDependencies', paths);
for i=1:length(a_array)
createTask(job_ss, @my_function, 0, {a_array(i)});
end
submit(job_ss)
when I run datafile.m on the matlab terminal it runs fine. However if I try to execute the script with the nohup command,the job fails. This is what I do:
nohup matlab -nodesktop <nohup_script.m &> nohup_script.log &
where nohup_script.m simply invokes datafile.m
I am wondering if it is not possible to use nohup with createTask and createJob command at all, or is it that I need to tweak my datafile.m to get it to work.
Solution
You need to modify your nohup_script.m
to block until job_ss
is complete. In other words, simply add
wait(job_ss)
to the end. Otherwise, the local scheduler terminates all running jobs when the invoking MATLAB client quits - as per the very last sentence on this page http://www.mathworks.co.uk/help/distcomp/use-a-local-scheduler.html
Answered By - Edric