Why Housekeeping Matters
Over time, Xi-Text systems accumulate jobs that are no longer needed and printers that are no longer in service. Retained jobs consume shared memory, old printer definitions clutter the display, and references to decommissioned remote hosts generate unnecessary network traffic. Regular housekeeping keeps the system manageable and helps administrators focus on what is actually in use.
This article walks through the process of exploring what is on the system, deciding what can be removed, and safely carrying out the cleanup.
Exploring the Job Queue
The sqlist command is the primary tool for reviewing jobs. By default, its output is terse, but the -H flag adds column headings and the -F format option lets you choose exactly which fields to display.
A useful format for housekeeping purposes includes the job number, owner, title, form type, submission time, printed status, and retention settings:
bash
sqlist -H -F "%N %u %h %f %W %q %t %T"
| Format code | Meaning |
|---|---|
| %N | Job number (includes host prefix for remote jobs) |
| %u | User who submitted the job |
| %h | Job title |
| %f | Form type |
| %W | Submission time |
| %q | Retain on queue flag |
| %t | Delete time if printed (hours) |
| %T | Delete time if not printed (hours) |
To restrict the view to a specific printer or user, add the -q and -u options:
bash
sqlist -H -q "oldprinter*" -F "%N %u %h %W" sqlist -H -u fred -F "%N %h %W %t"
For a fuller picture of an individual job, use spq and press O on the job to open the Other Options screen. This shows all attributes including whether the job has been printed, the hold time, deletion timeouts, and the page reached if printing was interrupted.
Identifying Stale Jobs
When reviewing the queue, look for the following indicators that a job may be a candidate for removal.
Jobs with old submission times : If the submission date is months or years ago and the job has not printed, it is very likely orphaned. Check with the owning user before removing.
Jobs retained after printing with no delete timeout : A retain flag with a delete timeout of zero means the job will remain on the queue indefinitely after printing. If the job has already printed and is no longer needed for reprinting, it can be removed.
Jobs targeted at printers that no longer exist : Use sqlist -H -F "%N %h %P" to see which printer each job is destined for. If the printer name no longer appears in splist, the job will never print.
Jobs with very large delete-if-unprinted timeouts : A job set to wait 8760 hours (one year) before automatic deletion may have been submitted speculatively and forgotten about.
Exploring Printer Status
The splist command shows all printers known to Xi-Text:
bash
splist -H
The output shows the printer name, device or network address, loaded form type, and current state. The states most relevant to housekeeping are:
Halted : The printer is not running. If it has been halted for a long time with no jobs queued for it, it may be unused.
Error : An unrecoverable error was detected. Check the system log file (spshed_reps in the spool directory) for details using the X command in spq. A printer permanently in error state may point to hardware that has been removed.
Offline : The printer has been detected as offline. Again, if this is persistent, the physical device may no longer be available.
For a scriptable overview, use the format option:
bash
splist -F "%p %d %f %t"
This outputs the printer name, device, form type, and state without any additional messages, making it straightforward to filter with grep or awk.
Checking Remote Host Availability
In a networked Xi-Text installation, some printers are hosted on remote machines. These appear in splist with the host name prefixed to the printer name, such as kira:hp5.
The remote hosts are defined in the Xi-Text hosts file, typically located at /etc/Xitext-hosts. Review this file to see which hosts are configured and their connection flags.
If a remote host is no longer available on the network, its printers will not function. You can test connectivity by attempting a manual connection:
bash
spconn hostname
If the host does not respond, any printers defined on that host are candidates for removal from the local configuration. Use spdisconn to cleanly disconnect from an unreachable host:
bash
spdisconn hostname
Bear in mind that removing a remote host's entry from the hosts file prevents Xi-Text from attempting to connect to it at startup, which avoids unnecessary delays.
Reviewing Printer Log Files
If printer definitions include a logfile keyword in their setup file, Xi-Text maintains an audit trail of every job printed on that printer. The log file is typically stored in the printer's definition directory under /usr/spool/printers/.
Each line in the log records the date, start time, finish time, user, title, form type, character count, device, printer name, priority, page count, and job number. This is invaluable for determining when a printer was last used.
To find the log file for a given printer, check the printer's setup file:
bash
grep "logfile=" /usr/spool/printers/printername/default
Then inspect the last few entries:
bash
tail -20 /usr/spool/printers/printername/.log
If the most recent entry is months or years old, the printer is likely no longer in active use.
For printers without log files enabled, you can check whether any jobs on the queue reference the printer:
bash
sqlist -F "%P" | grep -c "printername"
A count of zero means no jobs are currently targeting that printer.
Backing Up Before Cleanup
Before removing anything, create a backup of the current jobs and printers. Xi-Text provides utilities that export the current state as shell scripts which can recreate everything if needed.
To back up jobs:
bash
mkdir -p /usr/textsave/$(date +%Y%m%d)/Scripts cd /usr/textsave/$(date +%Y%m%d) cjlist -D /usr/spool/spd spshed_jfile Jcmd Scripts
This creates a shell script Jcmd that would resubmit all jobs, with the actual job data saved in the Scripts directory.
To back up printers:
bash
cplist -D /usr/spool/spd spshed_pfile Pcmd
This creates Pcmd, a shell script of spadd commands to recreate all printer definitions.
To back up user permissions:
bash
spuconv -D /usr/spool/spd spufile23 Ucmd
These backup scripts can be edited before restoration if you only need to recover specific items.
Safely Removing Jobs
Once you have confirmed a job is no longer needed, it can be removed in several ways.
Using spq interactively : Navigate to the job in the job list and press A to abort and delete it. If the job has not been printed, you will be asked to confirm. If it is currently printing, the print run will be aborted.
From the command line : Jobs can be deleted using their job number. The exact command depends on whether the job is currently printing or simply queued. In spq, the A key handles both cases.
For bulk removal, a scripted approach can be useful. For example, to identify all jobs submitted by a specific user:
bash
sqlist -u olduser -F "%N"
This lists just the job numbers, which can then be processed as needed.
If you are unsure about a job, you can unqueue it first using the U command in spq. This saves the job to a file and removes it from the queue, allowing it to be resubmitted later if needed. The command prompts for a directory, a command file name, and a data file name.
Safely Removing Printers
Printer removal is a two-stage process: first de-install from the active list, then remove the definition files.
- Halt the printer if it is running. In spq, move to the printer list, select the printer, and press H (halt at end of current job) or h (halt immediately, waiting for end of job). Alternatively use sphalt from the command line.
- De-install the printer from Xi-Text using the PTRUNINST script:
bash
/usr/spool/xi_distrib/Text/PTRUNINST
This presents a menu of installed printers. Select the one to remove and press Enter. The printer is removed from the active list but its definition files remain.
- Remove the printer definition using the PTRUNDEF script:
bash
/usr/spool/xi_distrib/Text/PTRUNDEF
Again, select the printer from the list. This removes the setup files from the printers directory.
Both scripts must be run as root. Xi-Text must be running when these scripts are executed.
If the printer is defined on a remote host, you can only de-install it from the host where it is defined. You may also need to remove or update the entry in the hosts file if the remote host itself is being decommissioned.
In spq, a printer can also be deleted from the printer list by pressing D, provided the printer is halted and you have the Add/delete printers privilege.
Housekeeping Checklist
A periodic review - quarterly or before major upgrades - should cover the following.
Review all jobs on the queue : Check submission dates, identify jobs with no printer target, and confirm retained jobs are still needed.
Review all printers : Identify printers permanently halted, in error, or offline. Confirm the underlying device or network address is still valid.
Check remote host connectivity : Verify that all hosts listed in the hosts file are still reachable and running Xi-Text.
Review printer log files : Identify printers that have not printed anything recently.
Back up before removing : Always run cjlist and cplist before deleting jobs or printers.
Document changes : Keep a record of what was removed and why, for audit purposes and in case something needs to be restored.
Notify users : If removing jobs belonging to other users or printers used by specific teams, inform them beforehand.
Best Practices
Schedule housekeeping during quiet periods when the print queue is not heavily loaded. Avoid removing printers whilst they are printing, as this will abort the current job.
When decommissioning a remote host, disconnect it cleanly with spdisconn before removing its entry from the hosts file. This avoids the scheduler attempting to reconnect during shutdown.
If shared memory is approaching capacity, removing old retained jobs and unused printer definitions frees slots immediately. Use spstart with appropriate sizing arguments when restarting Xi-Text after significant cleanup to right-size the allocated shared memory.
For systems with many printers and jobs, consider enabling log files on all printers if not already configured. This provides an ongoing audit trail that makes future housekeeping reviews much simpler.