forked from arnodelorme/child_mind_arno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getjobid.m
34 lines (30 loc) · 893 Bytes
/
getjobid.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function joblist = getjobid
try
[res,txt] = system('squeue -u arno');
rows = textscan(txt, '%s', 'delim', char(9));
rows = rows{1}
joblist = [];
iJob = 1;
for iRow = 2:length(rows)
tmp = textscan(rows{iRow}, '%s', 'delim', ' ');
tmp = tmp{1};
tmp(cellfun(@isempty, tmp)) = [];
if isequal(tmp{5}, 'R')
joblist(iJob).jobid = tmp{1};
joblist(iJob).partition = tmp{2};
joblist(iJob).jobname = tmp{3};
joblist(iJob).status = tmp{4};
joblist(iJob).time = datenum(tmp{6});
iJob = iJob+1;
end
end
if ~isempty(joblist)
[~,ind] = min([joblist.time]);
joblist = joblist(ind);
end
catch
joblist.jobid = datestr(now, 'yyyy-mm-dd_HH:MM');
end
if isempty(joblist)
joblist.jobid = datestr(now, 'yyyy-mm-dd_HH:MM');
end