Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2004
    Posts
    5

    Unanswered: Help to expalin cron problem

    Hey everyone

    Could you guys help me to understand what is going on here. I have this simple script(script A). When I run it from the command prompt of the "oracle" user account,it is successful (output A). But when I setup the job to run under the same oracle user's cron it fails (output B). Please help me to explain what is going here and how I can fix it.

    SCRIPT A:

    #!/bin/ksh -x
    #
    # SET GLOBAL VARIABLES
    DB="deltekcp griffon epay deltektc"
    #
    for x in $DB; do
    if [ `/u01/app/oracle/product/8.1.7/bin/tnsping $x | grep -c "^OK "` -ne 0 ]; then
    echo "$x : up"
    else
    echo "$x : down"
    fi
    done

    OUTPUT A:

    + DB=deltekcp griffon epay deltektc testcp
    + grep -c ^OK
    + /u01/app/oracle/product/8.1.7/bin/tnsping deltekcp
    + [ 1 -ne 0 ]
    + echo deltekcp : up
    deltekcp : up
    + grep -c ^OK
    + /u01/app/oracle/product/8.1.7/bin/tnsping griffon
    + [ 1 -ne 0 ]
    + echo griffon : up
    griffon : up
    + /u01/app/oracle/product/8.1.7/bin/tnsping epay
    + grep -c ^OK
    + [ 1 -ne 0 ]
    + echo epay : up
    epay : up
    + /u01/app/oracle/product/8.1.7/bin/tnsping deltektc
    + grep -c ^OK
    + [ 1 -ne 0 ]
    + echo deltektc : up
    deltektc : up


    OUTPUT B:

    + DB=deltekcp griffon epay deltektc testcp
    + grep -c ^OK
    + /u01/app/oracle/product/8.1.7/bin/tnsping deltekcp
    + [ 0 -ne 0 ]
    + echo deltekcp : down
    deltekcp : down
    + grep -c ^OK
    + /u01/app/oracle/product/8.1.7/bin/tnsping griffon
    + [ 0 -ne 0 ]
    + echo griffon : down
    griffon : down
    + grep -c ^OK
    + /u01/app/oracle/product/8.1.7/bin/tnsping epay
    + [ 0 -ne 0 ]
    + echo epay : down
    epay : down
    + grep -c ^OK
    + /u01/app/oracle/product/8.1.7/bin/tnsping deltektc
    + [ 0 -ne 0 ]
    + echo deltektc : down
    deltektc : down

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    When the cron daemon runs anything it doesn't set up the shell environment the way interactive shell does. This means in particular that /home/oracle/.profile does not get executed and as a result whatever environment variables should be set for Oracle utilities, aren't.

    You'll need to explicitly run the oracle user profile before doing anything else in your script, for example
    Code:
    #!...
    test -z "$ORACLE_HOME" && . /home/oracle/.profile
    # the rest of the script
    Last edited by n_i; 10-19-04 at 17:46.

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    ..............

  4. #4
    Join Date
    Jan 2004
    Posts
    5
    Thank you very much.

    This worked like a charm. Once I invoked the oracle profile the script ran fine.

  5. #5
    Join Date
    Jan 2004
    Posts
    5
    one question however, what is the ^ in the "^OK " doing?

  6. #6
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    Quote Originally Posted by telemorgan
    one question however, what is the ^ in the "^OK " doing?
    grep -c '^OK'
    number of lines beginning with string 'OK'
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •