vendredi 13 septembre 2019

Automation script for Autosys jobs

During patches/releases, my team has to manually off hold a large list of autosys jobs and I was tasked with automating the process using bash/ksh scripting. I am providing low quality pseudo code but was hoping someone could tell me if I'm way off or somewhat on the right track. The autosys jobs are provided in a text file and the script must pull the names and perform actions on them. Note: I am a novice programmer and there are likely many mistakes/incorrect logical decisions. Any advice or suggestions would be helpful. I just want to know if my approach is possible.

As noted, this is conceptual at this point and only pseudo code. I still need to fix so much. Keep in mind that the variable $JOB will return output like '149635_HIP_PILL' and $JOB_CONDITION will output the conditional jobs as such: 's(149632_AGG_READ)' but I am cutting only the job name, so no need for the 's'.

!/bin/bash

. opt/..........(servername)

JOB_LIST=cat joblist.txt JOB=i | cut -d ' ' -f1 JOB_CONDITIONS=jr $JOB -q | grep 'condition' | cut -d 's\()' -f1 CONDITION_STATUS=jr $GET_CONDITIONAL_JOB | grep 'SU' OFF_HOLD_JOB=sendevent -E JOB_OFF_HOLD -J $JOB_NAME`

For $JOB in $JOB_LIST do $JOB_CONDITIONS

For i in $JOB_CONDITIONS
do $CONDITION_STATUS

    if $CONDITION_STATUS='SU'
    then do
        $OFF_HOLD_JOB
    elif $CONDTION_STATUS != 'SU'
        echo "Required off hold conditions not met"
    fi
done

done

I want the code to step through each job name in the job list text file, and also return said job's conditional jobs. If the conditional jobs status is equal to "success or SU" I want to proceed with running the Off Hold autosys command - and if they don't, I want to stop the code and have users re-evaluate success criteria.

Aucun commentaire:

Enregistrer un commentaire