{"id":909,"date":"2016-08-25T22:31:28","date_gmt":"2016-08-25T20:31:28","guid":{"rendered":"http:\/\/www.netexpertise.eu\/en\/?p=909"},"modified":"2021-05-20T07:35:14","modified_gmt":"2021-05-20T05:35:14","slug":"list-as400-profiles-jobq","status":"publish","type":"post","link":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html","title":{"rendered":"List AS400 User Profiles and their Default JOBQ"},"content":{"rendered":"\n<p>I want to do a bit of cleanup on our main <a href=\"\/en\/tag\/ibm-i\">IBM i<\/a> because users jobs are running in all sort of queues. Most users have a dedicated JOBD and JOBQ, which is wrong in my humble opinion. A user&#8217;s JOBQ is defined within the user&#8217;s JOBD (Job Description). A JOBD references a JOBQ and can be assigned to as many users as you wish. The first thing I would need is a list of everybody&#8217;s default JOBQ.<br><br>I can get the job descriptions easily with the WRKUSRPRF command but getting all job queues at once is trickier.<br>If you&#8217;re familiar with PASE, it&#8217;s easy to get the job done and even assign new JOBDs to profiles based on their current value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><br>JOBD\/JOBQ List by User Profile<\/h2>\n\n\n\n<p>Connect to PASE environment either running &#8216;CALL QP2TERM&#8217; or <a href=\"\/en\/systems\/as400\/ssh-default-shell-and-command-history-on-as400.html\">SSH<\/a> if the service is set up and running.<br>Copy the following shell code into a file (let&#8217;s call it listJobq.sh) in the IFS, on your home directory for instance, make it executable<br>chmod +x listJobq.sh<br><br>and run:<br>.\/listJobq.sh<br><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">#!\/QOpenSys\/usr\/bin\/ksh\n\nIFS='\n'\n# Make sure the ADMIN library exists or use another\nsystem \"DSPUSRPRF USRPRF(*ALL) OUTPUT(*OUTFILE) OUTFILE(ADMIN\/USERLIST)\"\n\nprintf \"%11s%11s%11s\\n\" \"USRPRF\" \"JOBD\" \"JOBQ\"\n\nfor i in $(db2 \"select upuprf,upjbds from ADMIN.USERLIST\" | \\\n      sed -e '1,3 d' -e '\/^$\/ d' | sed -e '$ d'); do\n  unset IFS\n  set -A user $i\n  jobq=`system -i \"DSPJOBD JOBD(${user[1]})\" | awk '\/^ Fi\/ {print $NF;exit;}'`\n  printf \"%11s%11s%11s\\n\" \"${user[0]}\" \"${user[1]}\" \"$jobq\"\ndone<\/code><\/pre>\n\n\n\n<p>&nbsp;<br>This generates a list of USRPRF \/ JOBD \/ JOBQ. Most profiles now use the DEFAULT JOBD which sends users&#8217; jobs to the QBATCH JOBQ if not defined otherwise.<br><br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.netexpertise.eu\/images\/AS400_users_profile_JOBQ.png\" alt=\"AS400 users profile default JOBQ list\" width=\"272\" height=\"121\"\/><\/figure>\n\n\n\n<p><br>The system may return a &#8220;db2: cannot execute&#8221; or &#8220;\/usr\/bin\/db2: Permission denied&#8221; message. In this case, create a symbolic link like this:<br>ln -s \/QOpenSys\/usr\/bin\/qsh \/QOpenSys\/usr\/bin\/db2<br>The reason lies in this <a href=\"http:\/\/comp.sys.ibm.as400.misc.narkive.com\/hIIXY1N0\/using-db2-under-pase\">explanation<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><br>Bash Script Optimisation on PASE<\/h2>\n\n\n\n<p>The downside is the &#8220;system&#8221; command slowness. -i speeds things up a bit but it&#8217;s still not quick enough. If you have installed the OPS (Open Source) package from IBM along with matching PTF and bash, you can try this optimised version with hash tables in bash. <a href=\"https:\/\/www.ibm.com\/support\/pages\/getting-started-open-source-package-management-ibm-i-acs\">Opensource packages<\/a> can now be managed from the IBM i ACS user interface, which is very handy.<br>It stores jobd\/jobq in a hash table that acts as a cache since a jobd definition always returns the same job. If a lot of users have the same JOBD, it can be very efficient (35 times quicker in my case). This is a trick to get better performance for shell scripts on IBM i that are still running slow compared to x86 servers.<br>\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">#!\/usr\/bin\/bash\n\nIFS='\n'\ndeclare -A JOBQ\n\n# Make sure the ADMIN library exists or use another\nsystem \"DSPUSRPRF USRPRF(*ALL) OUTPUT(*OUTFILE) OUTFILE(ADMIN\/USERLIST)\"\n\nprintf \"%11s%11s%11s\\n\" \"USRPRF\" \"JOBD\" \"JOBQ\"\n\nfor i in $(db2 \"select upuprf,upjbds from ADMIN.USERLIST\" | \\\n      sed -e '1,3 d' -e '\/^$\/ d' | sed -e '$ d'); do\n  unset IFS\n  # Sets username and jobd in user[0] and user[1]\n  user=($i)\n  # Add jobq to hash table\n  if [ -z ${JOBQ[${user[1]}]} ]; then\n    jobq=`system -i \"DSPJOBD JOBD(${user[1]})\" | awk '\/^ Fi\/ {print $NF;exit;}'`\n    JOBQ[${user[1]}]=$jobq\n  fi\n  printf \"%11s%11s%11s\\n\" \"${user[0]}\" \"${user[1]}\" \"${JOBQ[${user[1]}]}\"\ndone<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I want to do a bit of cleanup on our main IBM i because users jobs are running in all sort of queues. Most users have a dedicated JOBD and JOBQ, which is wrong in my humble opinion. A user&#8217;s JOBQ is defined within the user&#8217;s JOBD (Job Description). A JOBD references a JOBQ and [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[210],"tags":[396,405,230,181],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Netexpertise - List AS400 User Profiles and their Default JOBQ<\/title>\n<meta name=\"description\" content=\"List AS400 user profiles and their default JOBQ with an optimised shell script. Organise user&#039;s Job Descriptions in a reusable manner\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Netexpertise - List AS400 User Profiles and their Default JOBQ\" \/>\n<meta property=\"og:description\" content=\"List AS400 user profiles and their default JOBQ with an optimised shell script. Organise user&#039;s Job Descriptions in a reusable manner\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html\" \/>\n<meta property=\"og:site_name\" content=\"Netexpertise\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-25T20:31:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-20T05:35:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.netexpertise.eu\/images\/AS400_users_profile_JOBQ.png\" \/>\n<meta name=\"author\" content=\"dave\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@netexpertise\" \/>\n<meta name=\"twitter:site\" content=\"@netexpertise\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html\",\"name\":\"Netexpertise - List AS400 User Profiles and their Default JOBQ\",\"isPartOf\":{\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#website\"},\"datePublished\":\"2016-08-25T20:31:28+00:00\",\"dateModified\":\"2021-05-20T05:35:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\"},\"description\":\"List AS400 user profiles and their default JOBQ with an optimised shell script. Organise user's Job Descriptions in a reusable manner\",\"breadcrumb\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.netexpertise.eu\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"List AS400 User Profiles and their Default JOBQ\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#website\",\"url\":\"https:\/\/www.netexpertise.eu\/en\/\",\"name\":\"Netexpertise\",\"description\":\"Systems \/ Networks \/ DevOps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.netexpertise.eu\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\",\"name\":\"dave\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"caption\":\"dave\"},\"sameAs\":[\"http:\/\/www.netexpertise.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Netexpertise - List AS400 User Profiles and their Default JOBQ","description":"List AS400 user profiles and their default JOBQ with an optimised shell script. Organise user's Job Descriptions in a reusable manner","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html","og_locale":"en_US","og_type":"article","og_title":"Netexpertise - List AS400 User Profiles and their Default JOBQ","og_description":"List AS400 user profiles and their default JOBQ with an optimised shell script. Organise user's Job Descriptions in a reusable manner","og_url":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html","og_site_name":"Netexpertise","article_published_time":"2016-08-25T20:31:28+00:00","article_modified_time":"2021-05-20T05:35:14+00:00","og_image":[{"url":"https:\/\/www.netexpertise.eu\/images\/AS400_users_profile_JOBQ.png"}],"author":"dave","twitter_card":"summary_large_image","twitter_creator":"@netexpertise","twitter_site":"@netexpertise","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html","url":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html","name":"Netexpertise - List AS400 User Profiles and their Default JOBQ","isPartOf":{"@id":"https:\/\/www.netexpertise.eu\/en\/#website"},"datePublished":"2016-08-25T20:31:28+00:00","dateModified":"2021-05-20T05:35:14+00:00","author":{"@id":"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa"},"description":"List AS400 user profiles and their default JOBQ with an optimised shell script. Organise user's Job Descriptions in a reusable manner","breadcrumb":{"@id":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/list-as400-profiles-jobq.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.netexpertise.eu\/en"},{"@type":"ListItem","position":2,"name":"List AS400 User Profiles and their Default JOBQ"}]},{"@type":"WebSite","@id":"https:\/\/www.netexpertise.eu\/en\/#website","url":"https:\/\/www.netexpertise.eu\/en\/","name":"Netexpertise","description":"Systems \/ Networks \/ DevOps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.netexpertise.eu\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa","name":"dave","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","caption":"dave"},"sameAs":["http:\/\/www.netexpertise.eu"]}]}},"_links":{"self":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/909"}],"collection":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/comments?post=909"}],"version-history":[{"count":0,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/909\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/media?parent=909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/categories?post=909"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/tags?post=909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}