Skip to content
Xi Software

The Xi-Batch Diagnostic Helper Functions

What the xib- shell library does, how to point it at your spool and job log, and where its output can mislead

Xi-BatchXi-Batchloggingmonitoringtroubleshooting

The Xi-Batch diagnostic helpers are a bash library of read-only shortcuts over btjlist, btvlist and the job log. They are supplied by Xi Software support. This article says how to obtain and source them, the two settings to make first, and where the library and a current installation disagree.

What the library contains

Functions whose names all begin xib-:

  • Read-only: every function is a btjlist, btvlist, grep or awk invocation. Nothing modifies a job, a variable or any system state.
  • Sourcing the file is the whole installation
  • They require bash. The functions use [[ ]] tests, the =~ match operator, local variables and the &> redirection, so a Bourne, Korn or C shell will reject the file

Two of the library's assumptions are wrong on a current installation, and both are covered below: the spool directory is looked for in two places that no current release uses, and the log-date functions build a two-digit year where the log writes four.

Obtaining and sourcing the library

The library is part of no Xi-Batch distribution: it is absent from the RPM, the Debian package and the tarball, the customer portal does not offer it, and the Xi-Batch manuals do not describe it. Ask Xi Software support for a copy, and confirm at the same time whether the version you are given is supported for your release.

The library needs bash. Its function names contain hyphens, which a POSIX shell rejects with a syntax error on the first line, so it cannot be sourced into sh, dash or the Korn shell that AIX and HP-UX default to. Where bash is absent, run the underlying btjlist and btvlist commands directly - each function is a wrapper around one of them.

Once you have the file, source it:

# One-time use
source /path/to/xib-helpers.sh

# Make available on every login
echo "source /path/to/xib-helpers.sh" >> ~/.bashrc

xib-help prints the function list, and xib-env what the library detected.

Set XIB_SPOOLDIR before you source it

This is the first thing to do on a current installation, and skipping it disables every log function.

The library looks for the spool directory in this order: the XIB_SPOOLDIR environment variable, then a SPOOLDIR environment variable, then two fixed paths - /usr/spool/batch and /var/spool/batch. The spool directory on a packaged installation is /var/spool/xi/batch, and the tarball installer uses the same value unless the operator changes it during installation. The two fixed paths are therefore wrong on every default installation of every distribution format, and the automatic detection fails.

Set the variable before sourcing:

export XIB_SPOOLDIR=/var/spool/xi/batch
source /path/to/xib-helpers.sh
xib-env

Confirm the real path first. It is the SPOOLDIR setting in the master configuration file /etc/xi/batchconfig:

grep SPOOLDIR /etc/xi/batchconfig

If your site uses the XIBATCH_ENV environment variable to run more than one Xi-Batch environment on a host, the spool directory in use is the configured path with that name appended, so read the value from the environment you are diagnosing.

SPOOLDIR is a configuration-file setting. Xi-Batch reads it from /etc/xi/batchconfig and never places it in the environment, so the library's SPOOLDIR fallback helps only where an administrator has exported it by hand.

What the failure looks like. When the spool directory cannot be found, xib-env prints NOT FOUND and every log function prints "Error: spool directory not found. Set XIB_SPOOLDIR." and returns 1. The affected functions are xib-history, xib-log-today, xib-log-errors, xib-log-on, xib-log-for-job and the second half of xib-compare-times.

The job and variable functions are unaffected. Everything built on btjlist and btvlist - the listing functions, xib-info, xib-script, xib-watch, xib-vars and xib-var - finds the spool directory through Xi-Batch itself and works whether or not XIB_SPOOLDIR is set.

Pointing at the job log

Xi-Batch writes a job log only when the LOGJOBS system variable holds a file name; it is empty on a new installation and there is no default log file. The library finds the log in this order: the XIB_LOGFILE environment variable; then the value of LOGJOBS read back with btvlist, resolved against the spool directory if it is a relative path; then the names joblog and logjob in the spool directory.

The two fallback names are guesses - Xi-Batch defines no default log file name - so the reliable routes are the first two. Check what your site uses:

btvlist -F "%N %V" | grep LOGJOBS

Then either rely on that value or set the path explicitly:

export XIB_LOGFILE=/var/spool/xi/batch/joblog
source /path/to/xib-helpers.sh

Log dates carry four-digit years

The job log line begins with the date in the form DD/MM/YYYY, followed by the time:

04/08/2026|07:30:12|1471|backup_daily|started|jsmith|users|150|1

Two helper functions anchor a date at the start of the line, and both build or document a two-digit year, so as shipped they match nothing:

  • xib-log-today builds the pattern with a two-digit year and returns no output on any release that writes four.
  • xib-log-on documents its argument as DD/MM/YY. Pass the four-digit form instead - xib-log-on 12/02/2026 works, because the function passes the argument straight through to grep.

Until the library is corrected, use grep directly for today's entries:

grep "^$(date +%d/%m/%Y)" /var/spool/xi/batch/joblog | tail -50

In time zones four or more hours west of UTC the product writes the day and month transposed, giving MM/DD/YYYY. Check one known line in your own log before writing any date pattern.

The short forms

Shorter than the equivalent command:

# Without helpers
btjlist -F "%N %H %U %T %P" | grep -E "Run|Strt|Init"

# With helpers
xib-list-running

Quick diagnostics:

xib-list-errors              # Jobs in error or abort state
xib-log-errors 50            # Last 50 error or abort log entries

Access by job title:

xib-info backup_daily        # Job details
xib-script backup_daily      # The job script
xib-history backup_daily     # Recent log entries

Ad-hoc monitoring:

xib-watch backup_daily       # Refreshes every 5 seconds
xib-compare-times report_weekly  # Schedule alongside recent history

What a job name is matched against

The functions that take a "job name" match against the job's title - the text set with btr -h or btjchange -h, shown by btjlist as %H. Three properties of a title affect how these functions behave:

  • Titles need not be unique. Where two jobs share one, the lookup returns the first match in queue order.
  • Titles may contain spaces. The lookups compare the second whitespace-separated column, so a title of "backup daily" cannot be found, and the field-position filters in xib-list-by-user and xib-list-by-queue select the wrong column whenever any listed job has a multi-word title.
  • A title may be empty, and a job the caller has no permission to read shows an empty title as well.

Where a job matters, work from its number. Every function that accepts a title also accepts the numeric job number and uses it directly:

xib-info 1471
xib-script 1471

Who may run them

btjlist and btvlist are installed set-user-id to the batch account, so any user can run them and the listing functions need no elevation. What a given user sees is decided by the Xi-Batch privilege model and by each job's read permission: a job the caller may not read is listed with its variable fields blank rather than refused.

The log functions are the exception. The job log is created owned by the batch account and, with the default permissions, readable by that account and its group alone. Reading it therefore needs the batch account, membership of its group, or root:

sudo -u batch -E bash -c 'source /path/to/xib-helpers.sh && xib-log-errors 20'

The -E flag preserves XIB_SPOOLDIR and XIB_LOGFILE across the elevation. Without it those overrides are dropped and the detection failure described above returns.

For a session of several commands:

sudo -u batch -E bash
source /path/to/xib-helpers.sh
xib-log-errors
xib-log-for-job backup_daily

The twenty-seven functions

xib-help prints the same list at the terminal.

Lookup

  • xib-name-to-id \ - job number for a title
  • xib-id-to-name \ - title for a job number

Listing

  • xib-list-all - every job, with a header
  • xib-list-running - jobs whose progress code is Run, Strt or Init
  • xib-list-errors - progress code Err or Abrt
  • xib-list-cancelled - progress code Canc
  • xib-list-done - progress code Done
  • xib-list-by-user [user] - defaults to the current user
  • xib-list-by-time \ - jobs whose next run time contains that text
  • xib-list-repeat - jobs with a repeat interval
  • xib-list-by-queue \
  • xib-list-by-pattern \ - case-insensitive match anywhere in the line

Job information

  • xib-info \ - a formatted summary line, then the default listing for that job</li> <li>xib-script \<title or number\> - the job script, via btjlist -V</li> <li>xib-history \<title or number\> [count] - log lines containing that text, last 20 by default</li> </ul> <p><strong>Analysis</strong></p> <ul> <li>xib-find-command \<command\> [directory] - files under the directory containing that text, current directory by default</li> <li>xib-check-repeat - see the note below</li> </ul> <p><strong>Log</strong></p> <ul> <li>xib-log-today - see the four-digit year note above</li> <li>xib-log-errors [count] - lines containing Error or Abort, case-insensitive</li> <li>xib-log-on \<date\> - lines beginning with that date</li> <li>xib-log-for-job \<title or number\> [count]</li> </ul> <p><strong>Variables</strong></p> <ul> <li>xib-vars - every variable with its value and comment</li> <li>xib-var \<name\></li> </ul> <p><strong>Monitoring and environment</strong></p> <ul> <li>xib-watch \<title or number\> [seconds] - repeats a btjlist line, 5 seconds by default</li> <li>xib-compare-times \<title or number\> - schedule alongside the last ten log entries</li> <li>xib-env - detected commands, paths and overrides</li> <li>xib-help - the function list</li> </ul> <h2 id="twofunctionsthatreportthewrongthing">Two functions that report the wrong thing</h2> <p><strong>xib-check-repeat reports nothing on any system.</strong> It looks for a repeat specification with three colon-separated parts and flags it as an extra parameter, restricting the search to Minutes, Hours, Days and Weeks. Those four units always print two parts. The three-part form is produced only for the two monthly repeat units, Monthsb and Monthse, where the third field is the day of the month and is entirely correct. The function's premise is therefore inverted and its pattern excludes the only case that could match.</p> <p><strong>xib-list-running omits jobs that are finishing.</strong> The progress codes are Done, Err, Abrt, Canc, Init, Strt, Run and Fin. The function searches for Run, Strt and Init, so a job in Fin is left out.</p> <p>Both functions also match against the whole output line, including the job title and the owner. A job titled "Error report" appears in xib-list-errors, and one titled "Runtime cleanup" appears in xib-list-running, whatever state either is really in. Confirm a match against btjlist before acting on it.</p> <h2 id="thejoblogline">The job log line</h2> <p>Job log lines are pipe-separated with nine fields:</p> <table> <col /> <col /> <thead> <tr> <th>Field</th> <th>Contents</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Date, DD/MM/YYYY</td> </tr> <tr> <td>2</td> <td>Time, HH:MM:SS</td> </tr> <tr> <td>3</td> <td>Job number</td> </tr> <tr> <td>4</td> <td>Job title, or a placeholder for an untitled job</td> </tr> <tr> <td>5</td> <td>Event, prefixed with "host:" for a job on another host</td> </tr> <tr> <td>6</td> <td>User</td> </tr> <tr> <td>7</td> <td>Group</td> </tr> <tr> <td>8</td> <td>Priority</td> </tr> <tr> <td>9</td> <td>Load level</td> </tr> </tbody> </table> <p>So the event of each recent failure is field 5:</p> <pre><code class="language-bash">xib-log-errors 100 | awk -F'|' '{print $1, $2, $3, $5}' </code></pre> <p>The variable log written by LOGVARS has a different layout and a variable field count, so the same field numbers do not apply to it.</p> <h2 id="workedsequences">Worked sequences</h2> <h3 id="amorningcheck">A morning check</h3> <pre><code class="language-bash">xib-list-running # What is currently active xib-list-errors # Anything that failed overnight xib-log-errors 20 # The log entries behind them </code></pre> <h3 id="investigatingonejob">Investigating one job</h3> <pre><code class="language-bash">xib-info 1471 # Job details xib-history 1471 50 # Recent log entries xib-script 1471 # The script </code></pre> <h3 id="findingjobsbycriteria">Finding jobs by criteria</h3> <pre><code class="language-bash">xib-list-by-time 07:30 # Jobs due at 07:30 xib-list-by-user jsmith # Jobs owned by jsmith xib-list-by-queue live # Jobs in the 'live' queue xib-list-repeat # Repeating jobs </code></pre> <h3 id="variables">Variables</h3> <pre><code class="language-bash">xib-vars # Every variable xib-var LOADLEVEL # One variable </code></pre> <h2 id="onsolarisaixandhp-ux">On Solaris, AIX and HP-UX</h2> <p>The library is written for Linux and needs adaptation on the commercial Unix platforms Xi-Batch also ships on.</p> <ul> <li><strong>bash is required</strong> and may live somewhere other than /bin on Solaris, AIX and HP-UX.</li> <li><strong>xib-watch calls the watch command</strong>, which is a Linux utility and is absent from a stock Solaris, AIX or HP-UX system. Use a shell loop with sleep instead.</li> <li><strong>/etc/profile.d is a Linux distribution convention.</strong> Where it exists, a file placed there is sourced for login shells only, so the functions are missing from cron jobs, from su without a login shell and from non-interactive scripts. Source the file explicitly in anything that depends on it.</li> <li><strong>sudo -u and sudo -E</strong> assume sudo is installed and configured; su - batch is the portable equivalent.</li> </ul> <h2 id="usingtheoutputelsewhere">Using the output elsewhere</h2> <p><strong>Export for analysis:</strong></p> <pre><code class="language-bash">xib-list-all > jobs-snapshot.txt xib-list-repeat | grep Days > daily-jobs.txt </code></pre> <p><strong>Pipe to standard tools:</strong></p> <pre><code class="language-bash">xib-list-by-user jsmith | wc -l </code></pre> <p><strong>In a script</strong>, source the library explicitly and set the overrides first, because a script has neither a login shell nor an interactive profile:</p> <pre><code class="language-bash">#!/bin/bash export XIB_SPOOLDIR=/var/spool/xi/batch source /path/to/xib-helpers.sh if xib-list-errors | grep -q "critical_load"; then echo "Critical job failed" | mail -s "Alert" ops@example.com fi </code></pre> <p>Check the exit status as well as the output: every function returns 1 with a message on standard error when a path or a job cannot be found, and an unchecked failure reads the same as a clean result.</p> <h2 id="thelimitsofthelibrary">The limits of the library</h2> <p>Every function reads. To start, stop or modify jobs, use the standard Xi-Batch commands - btjchange, btjdel, btr, btvar. For interactive job management, use btq.</p> <p>The manuals cover none of this, so where a helper and the standard command disagree, the standard command is the authority. Each function is built on one btjlist or btvlist command, which the library shows and which can be run directly.</p> <h2 id="whatgoeswrong">What goes wrong</h2> <p><strong>Functions not found:</strong> the file must be sourced rather than executed.</p> <pre><code class="language-bash">source xib-helpers.sh # Correct ./xib-helpers.sh # Defines the functions in a child shell that then exits </code></pre> <p><strong>"btjlist not found in PATH":</strong> the Xi-Batch commands are installed in /usr/local/bin on a packaged installation. Confirm with which btjlist and add the directory to PATH.</p> <p><strong>"spool directory not found":</strong> set XIB_SPOOLDIR as described above. This is expected on a current installation.</p> <p><strong>"job log file not found":</strong> either LOGJOBS is unset, so no job log exists, or the file name is one the library does not guess. Check with btvlist -F "%N %V" and set XIB_LOGFILE.</p> <p><strong>A log function returns nothing:</strong> check the year format in the log before assuming the log is empty, and check that you are reading it as the batch account.</p> <p><strong>Overrides lost under sudo:</strong> add -E.</p> <pre><code class="language-bash">export XIB_SPOOLDIR=/var/spool/xi/batch sudo -u batch -E bash -c 'source xib-helpers.sh && xib-env' </code></pre> <h2 id="anexamplesession">An example session</h2> <pre><code class="language-bash">export XIB_SPOOLDIR=/var/spool/xi/batch source /path/to/xib-helpers.sh xib-env # Confirm the paths were picked up xib-list-running xib-list-errors xib-info backup_daily xib-script backup_daily xib-list-by-time 07:30 xib-vars </code></pre> <p>And the log, as the batch account:</p> <pre><code class="language-bash">sudo -u batch -E bash -c 'source /path/to/xib-helpers.sh && xib-log-errors 20' </code></pre> <h2 id="relatedarticles">Related articles</h2> <div class="xi-card"> <h3 id="readingthexi-textsystemlogspshed_repsresourcesknowledge-basereading-the-xi-text-system-log-spshed-reps"><a href="/resources/knowledge-base/reading-the-xi-text-system-log-spshed-reps">Reading the Xi-Text System Log (spshed_reps)</a></h3> <p>What Xi-Text writes to its system log, the much longer list of what it never writes, and why rotating it destroys it</p> </div> <div class="xi-card"> <h3 id="trackingxi-batchjobactivitywithlogjobsresourcesknowledge-basetracking-xi-batch-job-activity-with-logjobs"><a href="/resources/knowledge-base/tracking-xi-batch-job-activity-with-logjobs">Tracking Xi-Batch Job Activity with LOGJOBS</a></h3> <p>Enabling the job log, reading its format, and rotating a file the scheduler never reopens</p> </div> <div class="xi-card"> <h3 id="trackingxi-batchvariablechangeswithlogvarsresourcesknowledge-basetracking-xi-batch-variable-changes-with-logvars"><a href="/resources/knowledge-base/tracking-xi-batch-variable-changes-with-logvars">Tracking Xi-Batch Variable Changes with LOGVARS</a></h3> <p>Enabling the variable log, reading a line whose field count varies, and telling which job made a change</p> </div> <p><a href="/resources/knowledge-base/">All articles</a> · <a href="/resources/release-notes">Release notes</a> · <a href="/contact?enquiry=Support">Contact support</a></p> </div> <p class="xi-modified"><time datetime="2026-08-20">Last updated: 20 August 2026</time></p> </div> </main> <footer class="xi-foot"> <div class="xi-in"> <div class="xi-foot-cols"> <div> <h2>Products</h2> <ul> <li><a href="/products/xi-batch">Xi-Batch</a></li> <li><a href="/products/xi-exec">Xi-Exec</a></li> <li><a href="/products/xi-text">Xi-Text</a></li> </ul> </div> <div> <h2>Detail</h2> <ul> <li><a href="/platforms">Platforms</a></li> <li><a href="/licensing">Licensing</a></li> <li><a href="/security">Security</a></li> </ul> </div> <div> <h2>Company</h2> <ul> <li><a href="/about">About</a></li> <li><a href="/distributors">Distributors</a></li> <li><a href="/contact">Contact</a></li> </ul> </div> </div> <p class="xi-legal"> <span>© 2026 Xi Software</span> <span><a href="https://lazysite.io">This is a Lazysite</a></span> </p> </div> </footer> <script> (function(){var b=document.querySelector('.xi-nav-toggle');if(!b)return; b.addEventListener('click',function(){var o=document.body.classList.toggle('xi-nav-open'); b.setAttribute('aria-expanded',o?'true':'false');});})(); </script> <script src="/assets/lazysite-chrome.js?v=0.10.19" defer></script></body> </html>