Introduction
How to Create a Refresh Job and Run via HVR Scheduler
Environment
Local Data Processing
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 = date in the file, then run the refresh job.
Resolution
So let's take this file ‘Myplans.csv’ with the example contents
2019-02-02
2019-02-09
2019-02-16
2019-02-23
And we have this script created
#!/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 will only create the refresh job in the scheduler but won’t start it. If you run this script without the ‘-s’ parameter to start the job immediately or you can keep this parameter to keep the job suspended then start the refresh job with hvrstart command.
Here is a snippet from the hvrrefresh wiki page@ https://www.hvr-software.com/docs/Hvrrefresh with more details:
Schedule 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 unsuspends 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. Jobs created are cyclic which means that after they have run they go back to PENDING state again. They are not generated by a trig_delay attribute which means that once they complete they will stay in PENDING state without getting retriggered. 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