How to Create and Run Refresh Job Using HVR Scheduler
Introduction
How to create and run a refresh job using HVR Scheduler?
Environment
HVR
Overview
Create a simple shell script to kick off a refresh of a table job from the HVR scheduler. It will check if the current date equals the date in the file, then run the refresh job.
Resolution
For example, let us take a file Myplans.csv
with the following contents:
2019-02-02
2019-02-09
2019-02-16
2019-02-23
Run the following script:
#!/bin/bash
currentdate=$(date "+%Y-%m-%d")
export HVR_HOME=/opt/hvr/hvr_home
export HVR_CONFIG=/opt/hvr/hvr_config
file="/home/oracle/Myplans.csv"
echo $file
if [ ! -f "$file" ]
then
echo "$0: File '${file}' not found."
else
dbdate=$(grep "$(date +"%Y-%m-%d")" $file)
if [ "${currentdate}" = "${dbdate}" ]; then
$HVR_HOME/bin/hvrrefresh -s -rMysource -lMytarget hubdb/password chn1
else
echo "Refresh did not start"
fi
fi
NOTE: The above script uses the -s parameter which only creates the refresh job in the scheduler but does not start it. You can run this script without the -s parameter to start the job immediately or use the parameter to keep the job suspended and start the refresh job with hvrstart command.
Schedule the invocation of refresh scripts using the HVR Scheduler. Without this option, the default behavior is to perform the refresh immediately. The jobs created by this option are named chn--refr-l1-l2
. These jobs are initially created in SUSPEND state. They can be invoked using command hvrstart as in the following example:
$ hvrstart -u -w hubdb chn-refr
The previous command un-suspends the jobs and instructs the Scheduler to run them. The output from the jobs is copied to the hvrstart command's stdout and the command finishes when all the jobs have finished. The jobs created are cyclic which means that after they are completed, they go back to the PENDING state again. They are not generated by a trig_delay attribute, which means that once they complete, they stay in the PENDING state without getting re-triggered. Once a refresh job has been created with option -s, then it can only be run on the command line (without HVR Scheduler) as follows:
$ hvrstart -i hubdb chn-refr-loc1-loc2