IBM Support

Page a user when a job abends in TWS

Question & Answer


Question

How do you set up mail on abend to page a user when a job abends in Tivoli Workload Scheduler (TWS)?

Answer

Notification of abended jobs can be configured in either the jobmanrc, .jobmanrc, or a recovery job. Notifying a user can be specified when any job abends or when job(s) that logon on as specific users abend. Notification can be accomplished via pager, email, or with other third party applications that have a command line interface. Below is a paging option.

Paging

Commands used to page someone using UNIX commands. Document a job that executes one of the following (this could also be included in either the jobmanrc or .jobmanrc as an action for abended jobs):

Solution 1:

echo “ATDT########@TTTTTTT” >> /dev/cua/b

Where
####### = pager number
TTTTTTT = text to send to pager
/dev/cua/b = serial port on UNIX system


Solution 2:

cu –lcu1p6 –s19200 `parms oncall` --2453000

The above uses the standard UNIX cu command; it pages the pager that is assigned to the parameter “oncall” with the text 2453000

Paging of abended jobs can be set up in several ways:

  • Use of "mail on abend" option in jobmanrc.
  • Use of exit code capturing in .jobmanrc
  • Use of recovery job

There are two files that are used to define how notification of abended jobs will be handled.

The file TWSHome/jobmanrc is used when notification of any abended job is required. The person notified will be identified in the jobmanrc file.

The file /userhome/.jobmanrc is used when notification of abended job is required for a specific user. The person notified is the owner of the job.

The TWSHome/jobmanrc has two sections that must be configured if this method will be used.

NOTE: The above files must be executable.

The following examples are for UNIX systems. The concept may be adapted for Windows but this will need to be done by the user.

Option 1 - "Mail on abend" in jobmanrc. By default no notification of abended jobs will occur when a job abends. If notification is desired, then two changes are required. Notification will be generated for any job that abends on this specific agent. As stated above, the notification can be in various forms. This option uses the built in feature "mail on abend" in TWS but will actually issue a page instead of an email. Refer to "Standard Configuration Script - jobmanrc" section in Chapter 1 of the TWS Reference Guide for more detailed information.

1. The TWSHome/jobmanrc file must be edited to invoke the "mail on abend". The option must be set to "YES"

The following changes must be made to jobmanrc for emailing of message of abended jobs.
# VARIABLE : MAIL_ON_ABEND
#
# MAIL_ON_ABEND is used to cause a message to be mailed when a job
# fails to run correctly (returns a nonzero exit code). Setting
# MAIL_ON_ABEND to "YES" will cause a message to be mailed to the
# mailbox for the logon user. This message will indicate the name of
# the stdlist file to be examined to determine the cause of the
# failure. Setting it to "NO" will skip the mail step. Any other
# value will be considered to be a user id to mail output to. A list
# could be specified if several users should be notified.
#
# DEFAULT : "NO"
# CRON Equivalent : "YES"
MAIL_ON_ABEND="NO"

if [ "$MAIL_ON_ABEND" != "NO" ]
then
USE_EXEC="NO"
fi


NOTE: The above line must have a "YES“, ROOT or valid user instead of a "NO"

2. The next required change of jobmanrc is toward the end of the file. This section will be configured to define who will be notified and the type of notification. The section will look at the value specified in the "MAIL_ON_ABEND" option to determine what action to perform. Each section has an action of issuing an email, this action can be replaced by one of the samples for issuing a page.

# Mail a message to user or to root if the job fails.

if [ "$MAIL_ON_ABEND" = "YES" ]
then
if [ $UNISON_RETURN -ne 0 ]
then
mail $LOGNAME <<-!
$UNISON_JOB
\'$UNISON_JCL\' failed with $UNISON_RETURN
Please review $UNISON_STDLIST
!
fi
elif [ "$MAIL_ON_ABEND" = "ROOT" ]
then
if [ $UNISON_RETURN -ne 0 ]
then
mail root <<-!
$UNISON_JOB
\'$UNISON_JCL\' failed with $UNISON_RETURN
Please review $UNISON_STDLIST
!
fi
elif [ "$MAIL_ON_ABEND" != "NO" ]
then
if [ $UNISON_RETURN -ne 0 ]
then
mail $MAIL_ON_ABEND <<-!
$UNISON_JOB
\'$UNISON_JCL\' failed with $UNISON_RETURN
Please review $UNISON_STDLIST
!
fi
fi

Sample:

if [ "$MAIL_ON_ABEND" = "YES" ]
then
if [ $UNISON_RETURN -ne 0 ]
then
echo “ATDT########@TTTTTTT” >> /dev/cua/b
fi



Option 2) - Exit code capturing in .jobmanrc. This option can be used to invoke notification of abended jobs for a specific user. This will require that a .jobmanrc file exist in the home of the job logon user. This file must be executable. Please refer to "Local Configuration Script - $HOME/.jobmanrc" section in Chapter 1 of TWS 8.2 Reference Guide for more detailed information.

1. The file .jobmanrc must be created in the job logon user's home directory. The function of the .jobmanrc is to setup the logon user's environment and any specific actions based on the exit codes of a job. The .jobmanrc will be executed anytime a job launches as the logon user for the agent where it exists. Below is a sample of a .jobmanrc and the necessary components:

Sample .jobmanrc

Example of a .jobmanrc (UNIX):
.jobmanrc
(specific to user)
#!/bin/ksh
## Maestro user .jobmanrc. The following line is required
PATH=$HOME:$HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/bin/X11:/usr/local/bin:$HOME/bin:.
export PATH
## The above PATH statement should also include the TWSHome and TWSHome/bin directories
## as the first entries after the "=" sign.

## Set up the shell environment or applications variables that may be
## be required ie .. Oracle DB2 etc....
..
..

## Here are some common aliases, the following is optional
## Just an example of what can be done
alias ls='ls -F'
alias sj='conman sj'
alias sc='conman sc'
alias ss='conman ss'
alias v='conman status'
alias cds='cd $STDLIST'
alias ll='ls -l'

## The following line is required
/bin/sh –c “$UNISON_JCL”


## The following text until the end of doc is optional but required if specific
## actions are necessary for nonzero exit codes

RETVAL=$?

## Error Handling procedures
## The following can be customized
## Check for exit code

if
[ "$RETVAL" -ne 0 ]
then
trap '(echo "mailing...stdlist to $LOGNAME"; sleep 30; mailx -s "Maestro job $UNISON_JOB" $LOGNAME < $UNISON_STDLIST) & ' 0

fi
## The is required
exit $RETVAL

As with Option 1, the action may be changed to issue a page.

Sample:

if
[ "$RETVAL" -ne 0 ]
then

echo “ATDT########@TTTTTTT” >> /dev/cua/b

fi
## The is required
exit $RETVAL


## The following is another example that can be used if a specific error code is not to be
## considered as reason for abending job.

if
[ "$RETVAL" –eg 101 ]
then
RETVAL=0

fi
exit $RETVAL


Option 3 - Use of a recovery job. This option can be used if the job that abends is a Windows job. The recovery job is included in the definition of the Windows job but can be a job that runs on a UNIX agent. The recovery job has several requirements:
  • The job must consist of a script
  • The script must run on a UNIX agent
  • The script must issue the page or email
  • The script must exit with a nonzero exit code. This is necessary to prevent the original abended job status from changing to "SUCC". Since the original job inherits the status of it's recovery job.

[{"Product":{"code":"SSGSPN","label":"IBM Workload Scheduler"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF025","label":"Platform Independent"},{"code":"PF033","label":"Windows"}],"Version":"8.5;8.5.1;8.6;9.1;9.2;9.3","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Product Synonym

Maestro;TWS;TWA

Document Information

Modified date:
17 June 2018

UID

swg21208511