-
1. Re: Set Schedule on a batch Job via NSH.
Bill RobinsonNov 13, 2015 2:30 PM (in response to Martin Gomez)
1 of 1 people found this helpfuluse Job addOneTImeSchedule.
and use the performance commands if you are going to be running a lot of commands in sequence
blcli_execute BatchJob getDBKeyByGroupAndName "/marty" "batchjob1"
blcli_storeenv BATCH_JOB_KEY
# Set the job schedule
DATE_STRING="2016-01-01 23:35:00"
blcli_execute Job addOneTimeSchedule ${BATCH_JOB_KEY} "${DATE_STRING}"
blcli_storeenv BATCH_JOB_KEY
....
-
2. Re: Set Schedule on a batch Job via NSH.
Martin Gomez Nov 13, 2015 3:06 PM (in response to Martin Gomez)Bill,
this is Just what I needed.
thank you
-
3. Re: Set Schedule on a batch Job via NSH.
Martin Gomez Nov 13, 2015 4:00 PM (in response to Bill Robinson)Bill,
if you are interested this is what I am doing with that. I have a PowerShell script that build a csv file and automatically generates the dates I need this to run based off of separation from the second Tuesday each month.
The CSV Looks like this.
BATCH_JOB_NAME,BATCH_JOB_GROUP,COMMIT_DATE,COMMIT_TIME
batchjobname,/batch/job/path,2016-01-15,22:00:00
here is the NSH.
#!/bin/nsh
HOST=
INPUT_CSV=# Process the command line
while getopts :h:i: Option
do
case $Option in
h) HOST=$OPTARG;;
i) INPUT_CSV=$OPTARG;;
\?) echo "Incorrect command line option."
exit 1;;
esac
doneassert ()
{
if test $1 -eq 11 ; then
return 0
elif test $1 -ne 0 ; then
echo "####### ERROR: $2; RC=$1" >&2
exit 1
fi
}# Check INPUT_CSV exists
if [ ! -f $INPUT_CSV ];then
echo "Input CSV [$INPUT_CSV] not found."
exit 1
fiINPUT_CSV_NUM_LINES=`cat $INPUT_CSV | wc -l`
LINE_CNT=2while [ $LINE_CNT -le $INPUT_CSV_NUM_LINES ]
do
input_csv_line=`sed -n "${LINE_CNT}p" $INPUT_CSV`
BATCHJOB=`echo $input_csv_line | cut -f1 -d,`
BATCHGROUP=`echo $input_csv_line | cut -f2 -d,`# Get the Batch Job DBKey using the above information.
BATCHJOB_DBKEY=`blcli_execute BatchJob getDBKeyByGroupAndName "${BATCHGROUP}" "${BATCHJOB}"`# Set the job schedule
DATE_STRING="2016-01-01 23:35:00"
BATCHJOB_KEY=`blcli_execute Job addOneTimeSchedule "${BATCHJOB_DBKEY}" "${DATE_STRING}"`
LINE_CNT=`expr $LINE_CNT + 1`
done -
4. Re: Set Schedule on a batch Job via NSH.
Bill RobinsonNov 13, 2015 4:30 PM (in response to Martin Gomez)
yeah - you should use the perf commands - your script will run a lot faster.
also - what's going on w/ all this:
INPUT_CSV_NUM_LINES=`cat $INPUT_CSV | wc -l`
LINE_CNT=2while [ $LINE_CNT -le $INPUT_CSV_NUM_LINES ]
do
input_csv_line=`sed -n "${LINE_CNT}p" $INPUT_CSV`
BATCHJOB=`echo $input_csv_line | cut -f1 -d,`
BATCHGROUP=`echo $input_csv_line | cut -f2 -d,`?
if you want to read all the lines except the header why not either not generate the header row in the csv or do like:
while IFS=, read BATCHJOB BATCHGROUP COMMIT_DATE COMMIT_TIME
do
DATE_STRING="${COMMIT_DATE} ${COMMIT_TIME}"
blcli_execute BatchJob getDBKeyByGroupAndName "${BATCHGROUP}" "${BATCHJOB}"
blcli_storeenv BATCH_JOB_KEY
# Set the job schedule
blcli_execute Job addOneTimeSchedule ${BATCH_JOB_KEY} "${DATE_STRING}"
blcli_storeenv BATCH_JOB_KEY
done <<< "$(grep -v "^BATCH_JOB_NAME" "${INPUT_CSV})"
-
5. Re: Set Schedule on a batch Job via NSH.
Martin Gomez Nov 13, 2015 9:57 PM (in response to Bill Robinson)I have around 30 batch jobs that I need to set schedules on. I use a powershell script to generate a csv file that has the name and path to the jobs. Then it calculates the cate based on patch Tuesday + xx days. Once the csv file has been created I can run the nsh script to set the schedule on all 30 jobs. Doing it this way takes 2-3 mintues vs and hour or so to set them manaually.
I use the same process to set the schedules on all of my windows patch jobs.
-
6. Re: Set Schedule on a batch Job via NSH.
Bill RobinsonNov 15, 2015 3:37 PM (in response to Martin Gomez)
?ok - the 'performance commands' (blcli_execute) will run faster than the normal blcli because a jvm is only started once. for calling the blcli 30 times you should see an improvement though this job doesn't seem time critical.
-
7. Re: Set Schedule on a batch Job via NSH.
Martin Gomez Nov 16, 2015 8:36 AM (in response to Bill Robinson)Bill,
Thanks. No these jobs are not time critical. I will normally set the schedules a week or so ahead of time. They need to run once a month. Just trying to avoid the tedious task of setting 30 schedules manually, along with the possibility of getting a date \ time wrong on one.
Martin Gomez
Lead Systems Administrator
816 435-6067
816 564-8876 (cell)
-
8. Re: Set Schedule on a batch Job via NSH.
Martin Gomez Nov 16, 2015 9:26 AM (in response to Bill Robinson)Bill,
Another thing worth noting. When the job runs and the format of the time is not correct. The target job executes NOW, instead of the set schedule just failing. I corrected my PowerShell script to ensure the time was 04:00:00 and it works as expected.
-
image001.png 4.2 K
-
-
9. Re: Set Schedule on a batch Job via NSH.
Bill RobinsonNov 16, 2015 9:35 AM (in response to Martin Gomez)
the above blclis are the only ones you are running? if the set schedule fails i would not expect the job to be executed.