Page 1 of 1

Avoid Instances--SH -c "dsjob -ljobs <Project> |

Posted: Fri Jan 26, 2007 10:09 am
by vinaymanchinila
Hi,
I need to find the total number of jobs in a project, I can use the

SH -c "dsjob -ljobs <Project> | wc -l"

But the issue is it also counts the instance of a job and bump the number way up, is there a way I can count Just the jobs and not instances?

Thanks,

Posted: Fri Jan 26, 2007 10:35 am
by jhmckeever
Hmm - My dsjob -ljobs just returns job names. Invocations are returned by dsjob -linvocations. Assuming your "dsjob -ljobs" is returning a list of JOBNAME.INVOCATIONID lines (!?), you can de-duplicate and count lines like this:

Code: Select all

SH -c "dsjob -ljobs <project> | cut -d'.' -f1 | uniq | wc -l"

J.

Posted: Fri Jan 26, 2007 10:43 am
by vinaymanchinila
I did try this and both commands give the same number !


SH -c "dsjob -ljobs Project1 | wc -l"


SH -c "dsjob -ljobs Project1 | cut -d'.' -f1 | uniq | wc -l "


Thanks for trying!

Posted: Fri Jan 26, 2007 10:46 am
by jhmckeever
Can you show us what you get from "dsjob -ljobs Project1"?

Posted: Fri Jan 26, 2007 10:58 am
by vinaymanchinila
I am sorry, I was wrong in calulating the first time, it does not count the instances for the following command

SH -c "dsjob -ljobs proj1 | wc -l"

thanks !

Posted: Fri Jan 26, 2007 11:02 am
by DSguru2B
Thats what i was going to say, dsjob -ljobs just retrieves the jobnames without their instances.

Posted: Fri Jan 26, 2007 11:07 am
by jhmckeever
Thank God - I thought this thread was about to reveal some mysterious new "dsjob" behaviour I'd never encountered. :-)

J.

Posted: Fri Jan 26, 2007 11:08 am
by DSguru2B
jhmckeever wrote:Thank God - I thought this thread was about to reveal some mysterious new "dsjob" behaviour I'd never encountered. :-)

J.
I felt the same. Thats why immediately tried the command to double check at my end and results came negative. :)