Defining additional environment variables in the service.env file

When a service is started, the environment in which the service process is started is inherited from the environment of the queue manager. It is possible to define additional environment variables to be set in the environment of the service process by adding the variables you want to define to one of the service.env environment override files.

About this task

There are two possible files to which you can add environment variables:
  • The machine scope service.env file
  • The queue manager scope service.env file

Both files are processed, if available, with definitions in the queue manager scope file taking precedence over those definitions in the machine scope file.

You can specify any environment variable in the service.env file. For example, if the IBM® MQ service runs a number of commands, it might be useful to set the PATH user variable in the service.env file.
Note: The values that you set the variable to cannot be environment variables; for example CLASSPATH= %CLASSPATH% is incorrect. Similarly, on Linux® PATH= $PATH :/opt/mqm/bin would give unexpected results.

CLASSPATH must be capitalized, and the class path statement can contain only literals. Some services (Telemetry for example) set their own class path. The CLASSPATH defined in service.env is added to it.

The format of the variables defined in the service.env file is a list of name and value variable pairs. Each variable must be defined on a new line, and each variable is taken as it is explicitly defined, including white space.

Procedure

  • Add environment variables to the machine scope service.env file.
    This file is located in:
    • [AIX][Linux]/var/mqm on AIX® and Linux systems.
    • [Windows]The data directory selected during installation on Windows systems.
  • Add environment variables to the queue manager scope service.env file.
    This file is located in the queue manager data directory. For example, the location of the environment override file for a queue manager named QMNAME is:
    • [AIX][Linux]On AIX and Linux systems, /var/mqm/qmgrs/QMNAME/service.env
    • [Windows]On Windows systems, C:\ProgramData\IBM\MQ\qmgrs\QMNAME\service.env

Example of a service.env file

  #********************************************************************#
  #*                                                                  *#
  #* <N_OCO_COPYRIGHT>                                                *#
  #* Licensed Materials - Property of IBM                             *#
  #*                                                                  *#
  #* 63H9336                                                          *#
  #* (C) Copyright IBM Corporation 2005, 2025.                        *#
  #*                                                                  *#
  #* <NOC_COPYRIGHT>                                                  *#
  #*                                                                  *#
  #********************************************************************#
  #***********************************************************************#
  #* Module Name: service.env                                            *#
  #* Type       : IBM MQ service environment file                        *#
  #* Function   : Define additional environment variables to be set      *#
  #*              for SERVICE programs.                                  *#
  #* Usage      : <VARIABLE>=<VALUE>                                     *#
  #*                                                                     *#
  #***********************************************************************#
  MYLOC=/opt/myloc/bin
  MYTMP=/tmp
  TRACEDIR=/tmp/trace
  MYINITQ=ACCOUNTS.INITIATION.QUEUE