Skip to content

Instantly share code, notes, and snippets.

@forstie
Created September 18, 2020 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save forstie/f3c4c9ba78f347c0afd9cfa1b20ca90b to your computer and use it in GitHub Desktop.
Save forstie/f3c4c9ba78f347c0afd9cfa1b20ca90b to your computer and use it in GitHub Desktop.
We were asked... how do you count the number of active user jobs "right now" and see the answer ordered by highest to lowest count. The answer is found below and I've included a version of the SQL that will work for anyone still using IBM i 7.1.
--
-- description: Count the number of active user jobs in the system
-- minvrm: v7r2m0
--
select authorization_name as user_name, count(*) as active_job_count
from table (
qsys2.active_job_info()) j
where job_type <> 'SYS' and job_status not in ('PSRW') and
j.authorization_name not in (select user_name
from qsys2.user_info
where user_creator = '*IBM')
group by authorization_name
order by 2 desc;
--
-- description: Count the number of active user jobs in the system
-- minvrm: v7r1m0
--
select authorization_name as user_name, count(*) as active_job_count
from table (
qsys2.active_job_info('NO', '', '', '')
) j
where job_type <> 'SYS' and job_status not in ('PSRW') and
j.authorization_name not in (select user_name
from qsys2.user_info
where user_creator = '*IBM')
group by authorization_name
order by 2 desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment