Customizing output format and reducing network traffic for IBM® Spectrum LSF job queries

The default bjobs command output provides basic job information. When you need additional job information, you might prefer to have the job output displayed line by line. Controlling the format of bjobs output can also make the output easily parsed by scripts and also reduce network traffic by transferring only the required information from mbatchd to the bjobs command.

LSF supports three ways to customize job query output and information returned from mbatchd:

  • LSB_BJOBS_FORMAT defined in lsf.conf as default job query output.
  • LSB_BJOBS_FORMAT defined as an environment variable to override the parameters configured in lsf.conf
  • bjobs -o option to define a job output format that overrides both the LSB_BJOBS_FORMAT environment variable and the parameter in lsf.conf

The following job query output format is supported by LSB_BJOBS_FORMAT and bjobs -o:

"field_name[:[-][output_width]] ... [delimiter='character']"

Where:

field_name
Sets bjobs fields or aliases instead of the full field names, sets recommended width for the specified field, and sets right justification for the specific field
output_width
Sets output width for the specified field
delimiter
Sets the delimiting character to display between different headers and fields.
character
A single character as delimiter. By default, the delimiter is a space.

Here are a few examples to show bjobs -o usage. See the IBM LSF Command Reference for detailed information about bjobs -o.

  • bjobs -o "jobid exec_host"

    A single line output to display all spanning execution hosts for every job.

    # bjobs -o "jobid exec_host"
    JOBID EXEC_HOST
    2593  lsfrhel02:lsfrhel02:lsfrhel02
    2594  lsfrhel02:lsfrhel02:lsfrhel02
    2595  lsfrhel02:lsfrhel02:lsfrhel01:lsfrhel01:lsfrhel01
  • bjobs -o "jobid exec_host:-50"

    A single line output to display all spanning execution hosts for every job. Field exec_host is displayed right justified with a 50 character width.

    # bjobs -o "jobid exec_host:-50"
    JOBID EXEC_HOST
    2593  lsfrhel02:lsfrhel02:lsfrhel02
    2594  lsfrhel02:lsfrhel02:lsfrhel02
    2595  lsfrhel02:lsfrhel02:lsfrhel01:lsfrhel01:lsfrhel01
  • bjobs -o "jobid exec_host delimiter=’/’"

    A single line output to display all spanning execution hosts for every job. Slash (/) is used as the delimiter for each field.

    # bjobs -o "jobid exec_host delimiter='/'"
    JOBID/EXEC_HOST
    2593/lsfrhel02:lsfrhel02:lsfrhel02
    2594/lsfrhel02:lsfrhel02:lsfrhel02
    2595/lsfrhel02:lsfrhel02:lsfrhel01:lsfrhel01:lsfrhel01
  • bjobs

    With LSB_BJOBS_FORMAT defined in lsf.conf or defined as environment variable, the default output display of bjobs can be customized to show only the fields you want.

    LSB_BJOBS_FORMAT="ID: STAT: QUEUE: USER: NAME: MAX_REQ_PROC: FIRST_HOST: CPU_USED:12 MEM: "
    # bjobs
    JOBID STAT QUEUE  USER  JOB_NAME   MAX_REQ_PROC FIRST_HOST CPU_USED     MEM
    2596  RUN  normal user1 testrun    4            lsfrhel01  26 second(s) 2 Mbytes
    2597  RUN  normal user1 bigmem_run 100          lsfrhel02  1 second(s)  2 Mbytes