Oracle Analytics Cloud and Server

Welcome to the Oracle Analytics Community: Please complete your User Profile and upload your Profile Picture

Task scheduling - crontab

Received Response
21
Views
6
Comments
Daniel Gerçossimo
Daniel Gerçossimo Rank 3 - Community Apprentice

Good morning community!

I am Brazilian
, and as I have no command of the language I write in the google translator, so sorry about the bad grammar.

I created a script to back up the repository and catalog, manually rotate works right, but I want to schedule it run once a week, I created the scheduling crontab but the script does not run, I have done many researches on the net changed the script so many times and still does not work. I checked and the crontab is calling the script.

In the research I read that it was necessary to add the Oracle environment variables but do not know what are the variables that I use. And I do not know if that's why it does not work.

The version of BI is 12.2.1.0.0 (Build-BIPS 20,151,008,013,645 64-bit) and the OS is Red Hat Enterprise Linux Server release 6.7 64-bit

I thank the collaboration of all.

Daniel.

Answers

  • rmoff
    rmoff Rank 6 - Analytics Lead

    Usually the mistake made with crontab  (and I always make it) is that it runs with no environment set, whereas when you test the script you'd usually do it from the user's login shell which will have various paths etc already set.

    So the crontab may be running, but failing.

    You can test running it with su without the - usually used, to stop it running the login shell.

    So if your backup script is /home/oracle/foo.sh, you could run:

    su -c '/home/oracle/foo.sh'
    

    and see if it succeeds.

    the script does not run
    

    Please be more precise. Do you get an error?

  • Daniel Gerçossimo
    Daniel Gerçossimo Rank 3 - Community Apprentice

    It does not generate error message and have tried to root.

    follows the
    script:


    #/bin/bash

    function dowRpd(){

        atualizaData

        ${DIR_SCRIPTS}data-model-cmd.sh downloadrpd -O ${DIR_BKP}${DIR_RPD}OracleBi-${DATA}.rpd -SI ssi -U ${USUARIO} -W ${PASS} -P ${PASS} >> $ARQ_LOG 2>&1

    }

    function dowCat(){

        atualizaData

        ${DIR_SCRIPTS}runcat.sh -cmd archive -online http://172.17.0.101:9502/analytics/saw.dll -credentials ${DIR_BKP}credentials -forceOutputFile ${DIR_BKP}${DIR_CAT}catalogo-${DATA}.catalog -folder /shared >> $ARQ_LOG 2>&1

    }

    function upRpd(){

        dowRpd

        atualizaData

        ${DIR_SCRIPTS}data-model-cmd.sh uploadrpd -I ${DIR_BKP}${DIR_RPD}OracleBi.rpd -SI ssi -U ${USUARIO} -W ${PASS} -P ${PASS} >> $ARQ_LOG 2>&1

    }

    function atualizaData(){

        DATA=$(date +%Y-%m-%d-%Hh%Mm%Ss) >> $ARQ_LOG

    }

    VERSION="1.0.002"

    USUARIO=`grep -i "login" credentials`

    USUARIO="${USUARIO#login=}"

    PASS=`grep -i "pwd" credentials`

    PASS="${PASS#pwd=}"

    DIR_SCRIPTS="/data/app/oracle/product/Middleware/Oracle_Home/user_projects/domains/bi/bitools/bin/"

    DIR_BKP="/data/app/oracle/product/Middleware/Oracle_Home/BackUps/"

    DIR_RPD="Repositorios/"

    DIR_CAT="Catalogos/"

    DIR_LOG="Logs/"

    ARQ_LOG=${DIR_BKP}${DIR_LOG}"RpdCat.log"

    while getopts "ud:vh" OPTION

    do

        case $OPTION in

            u) DO_UP=1

                ;;

            d) DO_DOW=1

                OPD=$OPTARG

                ;;

            ?) exit 1

                ;;

        esac

    done

    shift $((OPTIND-1))

    if [ -z "$DO_UP" ] && [ -z "$DO_DOW" ]; then

        exit 1

    fi

    if [ "$ARQ_LOG" ]; then

        atualizaData

       

        if [ "$DO_DOW" == 1 ]; then

            case $OPD in

                f)    dowRpd

                    dowCat

                    ;;

                r)    dowRpd

                    ;;

                c)    dowCat

                    ;;

                ?) exit 1

                    ;;

            esac

        fi

       

        if [ "$DO_UP" == 1 ]; then

            upRpd

        fi

       

        atualizaData

    fi

    exit 0

    and cron:

    SHELL=/bin/bash

    PATH=/sbin:/bin:/usr/sbin:/usr/bin

    MAILTO=root

    HOME=/

    ###BACKUP CODIUB###

    00 04 * * 0 /data/app/oracle/product/Middleware/Oracle_Home/BackUps/CRONCodiubBackupsRPDeCAT.sh -d f

  • rmoff
    rmoff Rank 6 - Analytics Lead

    What user is the crontab under?

    So if you run /data/app/oracle/product/Middleware/Oracle_Home/BackUps/CRONCodiubBackupsRPDeCAT.sh -d f it works just fine? What about putting a >> /tmp/foo.log 2>&1 on the end of the crontab statement to see output? Do you know for sure that the crontab is even executing in the first place?

    BTW in the top-right of the message editor is "Use advanced editor" and from there you can post syntax highlighted code

  • Daniel Gerçossimo
    Daniel Gerçossimo Rank 3 - Community Apprentice

    ok, I'll do a test and return to the result.

    thank you so much

  • Daniel Gerçossimo
    Daniel Gerçossimo Rank 3 - Community Apprentice

    It worked.


    Look at the log and realized that the credentials file was relative path and thus would not start the user and password information.


    I changed the script and looked like this:

    #/bin/bash

    function dowRpd(){

        atualizaData

        ${DIR_SCRIPTS}/data-model-cmd.sh downloadrpd -O ${DIR_BKP}/${DIR_RPD}/OracleBi-${DATA}.rpd -SI ssi -U ${USUARIO} -W ${PASS} -P ${PASS} >> $ARQ_LOG 2>&1

    }

    function dowCat(){

        atualizaData

        ${DIR_SCRIPTS}/runcat.sh -cmd archive -online http://172.17.0.101:9502/analytics/saw.dll -credentials ${DIR_BKP}/credentials -forceOutputFile ${DIR_BKP}/${DIR_CAT}/catalogo-${DATA}.catalog -folder /shared >> $ARQ_LOG 2>&1

    }

    function upRpd(){

        dowRpd

        atualizaData

        ${DIR_SCRIPTS}/data-model-cmd.sh uploadrpd -I ${DIR_BKP}/${DIR_RPD}/OracleBi.rpd -SI ssi -U ${USUARIO} -W ${PASS} -P ${PASS} >> $ARQ_LOG 2>&1

    }

    function atualizaData(){

        DATA=$(date +%Y-%m-%d-%Hh%Mm%Ss) >> $ARQ_LOG

    }

    VERSION="1.0.002"

    DIR_SCRIPTS="/data/app/oracle/product/Middleware/Oracle_Home/user_projects/domains/bi/bitools/bin"

    DIR_BKP="/data/app/oracle/product/Middleware/Oracle_Home/BackUps"

    DIR_RPD="Repositorios"

    DIR_CAT="Catalogos"

    DIR_LOG="Logs"

    ARQ_LOG=${DIR_BKP}/${DIR_LOG}/"RpdCat.log"

    USUARIO=`grep -i "login" ${DIR_BKP}/credentials`

    USUARIO="${USUARIO#login=}"

    PASS=`grep -i "pwd" ${DIR_BKP}/credentials`

    PASS="${PASS#pwd=}"

    while getopts "ud:vh" OPTION

    do

        case $OPTION in

            u) DO_UP=1

                ;;

            d) DO_DOW=1

                OPD=$OPTARG

                ;;

            ?) exit 1

                ;;

        esac

    done

    shift $((OPTIND-1))

    if [ -z "$DO_UP" ] && [ -z "$DO_DOW" ]; then

        exit 1

    fi

    if [ "$ARQ_LOG" ]; then

        atualizaData

       

        if [ "$DO_DOW" == 1 ]; then

            case $OPD in

                f)    dowRpd

                    dowCat

                    ;;

                r)    dowRpd

                    ;;

                c)    dowCat

                    ;;

                ?) exit 1

                    ;;

            esac

        fi

       

        if [ "$DO_UP" == 1 ]; then

            upRpd

        fi

       

        atualizaData

    fi

    exit 0

    Thank you so much.

    Daniel.

  • rmoff
    rmoff Rank 6 - Analytics Lead

    Glad it worked.