Customizing job processing for a user on UNIX® workstations - .jobmanrc

About this task

On UNIX® workstations, the local configuration script .jobmanrc permits users to establish a required environment when processing their own jobs. Unlike the jobmanrc script, the .jobmanrc script can be customized to perform different actions for different users. Each user defined as tws_user can customize in the home directory the .jobmanrc script to perform pre- and post-processing actions. The .jobmanrc script is an extra step that occurs before the job is actually launched.

The .jobmanrc script runs only under the following conditions:
  • The standard configuration script, jobmanrc, is installed, and the environment variable LOCAL_RC_OK is set to yes (see Variables defined by default in the jobmanrc file).
  • If the file TWS_home/localrc.allow exists, the user's name must appear in the file. If the TWS_home/localrc.allow file does not exist, the user's name must not appear in the file, TWS_home/localrc.deny. If neither of these files exists, the user is permitted to use a local configuration script.
  • The local configuration script is installed in the user's home directory (USER_home/.jobmanrc), and it has execute permission.
Jobs are not automatically run, the command or script must be launched from inside the .jobmanrc. Depending on the type of process activity you want to perform, the command or script is launched differently. Follow these general rules when launching scripts from inside .jobmanrc:
  • Use eval if you want to launch a command.
  • Use either eval or exec if you want to launch a script that does not need post processing activities.
  • Use eval if you want to launch a script that requires post processing activities.
If you intend to use a local configuration script, it must, at a minimum, run the job's script file ($UNISON_JCL). HCL Workload Automation provides you with a standard configuration script, jobmanrc, which runs your local configuration script as follows:
$EXECIT $USE_SHELL $USER_home/.jobmanrc "$UNISON_JCL" $IS_COMMAND
where:

All the variables exported into jobmanrc are available in the .jobmanrc shell, however, variables that are defined, but not exported, are not available.

The following example shows how to run a job's script file, or command, in your local configuration script:
#!/bin/ksh
PATH=TWS_home:TWS_home/bin:$PATH
export PATH
/bin/sh -c "$UNISON_JCL"
The following is an example of a .jobmanrc that does processing based on the exit code of the user's job:
#!/bin/sh
#
PATH=TWS_home:TWS_home/bin:$PATH
export PATH
/bin/sh -c "$UNISON_JCL"
#or use eval "$UNISON_JCL" and the quotes are required
RETVAL=$?
if [ $RETVAL -eq 1 ]
then
echo "Exit code 1 - Non Fatal Error"
exit 0
elif [ $RETVAL -gt 1 -a $RETVAL -lt 100 ]
then
conman "tellop This is a database error - page the dba"
elif [ $RETVAL -ge 100 ]
then
conman "tellop Job aborted. Please page the admin"
fi

If jobs on dynamic agents fail with exit code 126 displaying error "script.sh: cannot execute [Text file busy]", and .jobmanrc is used, add the following:
eval $JCL

stat=$?

if [ $stat -eq 126 ]

then

echo "JOB ERROR: The command $JCL ended with error 126."

echo "JOB ERROR: try the workaround"

echo running ksh $JCL

ksh $JCL

stat=$?

if [ $stat -eq 126 ]

then

echo "#!/bin/ksh" > $HOME/tmp.$$.sh

echo $JCL >> $HOME/tmp.$$.sh

chmod +x $HOME/tmp.$$.sh

echo running ksh $HOME/tmp.$$.sh

ksh $HOME/tmp.$$.sh

stat=$?

rm $HOME/tmp.$$.sh

else

echo "JOB OK: using workaround 1, exit code=$stat"

fi

fi

echo rc $stat

exit $stat