An administrator can write prolog and epilog user exits that can run before and after a LoadLeveler job runs, respectively.
Prolog and epilog programs fall into two categories: those that run as the LoadLeveler user ID, and those that run in a user's environment.
To specify prolog and epilog programs, specify the following keywords in the configuration file:
A user environment prolog or epilog runs with AFS and/or DCE authentification (if either is installed and enabled). For security reasons, you must code these programs on the machines where the job runs and on the machine that schedules the job. If you do not define a value for these keywords, the user enviroment prolog and epilog settings on the executing machine are ignored.
The user environment prolog and epilog can set environment variables for the job by sending information to standard output in the following format:
env id = value
Where:
For example, the user environment prolog below sets the environment variable STAGE_HOST for the job:
#!/bin/sh echo env STAGE_HOST=shd22
The prolog program is invoked by the starter process. Once the starter process invokes the prolog program, the program obtains information about the job from environment variables.
prolog_program
Where prolog_program is the name of the prolog program as defined in the JOB_PROLOG keyword.
No arguments are passed to the program, but several environment variables are set. For more information on these environment variables, see Run-time Environment Variables.
The real and effective user ID of the prolog process is the LoadLeveler user ID. If the prolog program requires root authority, the administrator must write a secure C or perl program to perform the desired actions. You should not use shell scripts with set uid permissions, since these scripts may make your system susceptible to security problems.
If the prolog program is killed, the job does not begin and a message is written to the starter log.
#!/bin/ksh # # Set up environment set -a . /etc/environment . /.profile export PATH="$PATH:/loctools/lladmin/bin" export LOG="/tmp/$LOADL_STEP_OWNER.$LOADL_JOB_ID.prolog" # # Do set up based upon job step class # case $LOADL_STEP_CLASS in # A OSL job is about to run, make sure the osl filesystem is # mounted. If status is negative then filesystem cannot be # mounted and the job step should not run. "OSL") mount_osl_files >> $LOG if [ status = 0 ] then EXIT_CODE=1 else EXIT_CODE=0 fi ;; # A simulation job is about to run, simulation data has to # be made available to the job. The status from copy script must # be zero or job step cannot run. "sim") copy_sim_data >> $LOG if [ status = 0 ] then EXIT_CODE=0 else EXIT_CODE=1 fi ;; # All other job will require free space in /tmp, make sure # enough space is available. *) check_tmp >> $LOG EXIT_CODE=$? ;; esac # The job step will run only if EXIT_CODE == 0 exit $EXIT_CODE
#!/bin/csh # # Set up environment source /u/loadl/.login # setenv PATH "${PATH}:/loctools/lladmin/bin" setenv LOG "/tmp/${LOADL_STEP_OWNER}.${LOADL_JOB_ID}.prolog" # # Do set up based upon job step class # switch ($LOADL_STEP_CLASS) # A OSL job is about to run, make sure the osl filesystem is # mounted. If status is negative then filesystem cannot be # mounted and the job step should not run. case "OSL": mount_osl_files >> $LOG if ($status < 0 ) then set EXIT_CODE = 1 else set EXIT_CODE = 0 endif breaksw # A simulation job is about to run, simulation data has to # be made available to the job. The status from copy script must # be zero or job step cannot run. case "sim": copy_sim_data >> $LOG if ($status == 0 ) then set EXIT_CODE = 0 else set EXIT_CODE = 1 endif breaksw # All other job will require free space in /tmp, make sure # enough space is available. default: check_tmp >> $LOG set EXIT_CODE = $status breaksw endsw # The job step will run only if EXIT_CODE == 0 exit $EXIT_CODE
The installation defined epilog program is invoked after a job step has completed. The purpose of the epilog program is to perform any required clean up such as unmounting file systems, removing files, and copying results. The exit status of both the prolog program and the job step is set in environment variables.
epilog_program
Where epilog_program is the name of the epilog program as defined in the JOB_EPILOG keyword.
No arguments are passed to the program but several environment variables are set. These environment variables are described in Run-time Environment Variables. In addition, the following environment variables are set for the epilog programs:
To interpret the exit status of the prolog program and the job step, convert the string to an integer and use the structures found in the sys/wait.h file.
#!/bin/ksh # # Set up environment set -a . /etc/environment . /.profile export PATH="$PATH:/loctools/lladmin/bin" export LOG="/tmp/$LOADL_STEP_OWNER.$LOADL_JOB_ID.epilog" # if [ [ -z $LOADL_PROLOG_EXIT_CODE ] ] then echo "Prolog did not run" >> $LOG else echo "Prolog exit code = $LOADL_PROLOG_EXIT_CODE" >> $LOG fi # if [ [ -z $LOADL_USER_PROLOG_EXIT_CODE ] ] then echo "User environment prolog did not run" >> $LOG else echo "User environment exit code = $LOADL_USER_PROLOG_EXIT_CODE" >> $LOG fi # if [ [ -z $LOADL_JOB_STEP_EXIT_CODE ] ] then echo "Job step did not run" >> $LOG else echo "Job step exit code = $LOADL_JOB_STEP_EXIT_CODE" >> $LOG fi # # # Do clean up based upon job step class # case $LOADL_STEP_CLASS in # A OSL job just ran, unmount the filesystem. "OSL") umount_osl_files >> $LOG ;; # A simulation job just ran, remove input files. # Copy results if simulation was successful (second argument # contains exit status from job step). "sim") rm_sim_data >> $LOG if [ $2 = 0 ] then copy_sim_results >> $LOG fi ;; # Clean up /tmp *) clean_tmp >> $LOG ;; esac
#!/bin/csh # # Set up environment source /u/loadl/.login # setenv PATH "${PATH}:/loctools/lladmin/bin" setenv LOG "/tmp/${LOADL_STEP_OWNER}.${LOADL_JOB_ID}.prolog" # if ( ${?LOADL_PROLOG_EXIT_CODE} ) then echo "Prolog exit code = $LOADL_PROLOG_EXIT_CODE" >> $LOG else echo "Prolog did not run" >> $LOG endif # if ( ${?LOADL_USER_PROLOG_EXIT_CODE} ) then echo "User environment exit code = $LOADL_USER_PROLOG_EXIT_CODE" >> $LOG else echo "User environment prolog did not run" >> $LOG endif # if ( ${?LOADL_JOB_STEP_EXIT_CODE} ) then echo "Job step exit code = $LOADL_JOB_STEP_EXIT_CODE" >> $LOG else echo "Job step did not run" >> $LOG endif # # Do clean up based upon job step class # switch ($LOADL_STEP_CLASS) # A OSL job just ran, unmount the filesystem. case "OSL": umount_osl_files >> $LOG breaksw # A simulation job just ran, remove input files. # Copy results if simulation was successful (second argument # contains exit status from job step). case "sim": rm_sim_data >> $LOG if ($argv{2} == 0 ) then copy_sim_results >> $LOG endif breaksw # Clean up /tmp default: clean_tmp >> $LOG breaksw endsw