Thread: Unix Crontab

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    1
    Rep Power
    0

    Question Unix Crontab


    Hi
    i have written a shell script which runs some sql queries in oracle.
    the code looks like this

    sqlplus username@NJCMTOMS/password < $HOME/devel/oms/arg/cleanupsql.sh

    cleanupsql.sh has the sqls to be executed.

    This works fine if i run from the prompt but when i run from a cron,then cron is not able to find sqlplus.i also tried giving the absolute path for sqlplus ,still no success.

    Pls tell me what is the exact way of doing this.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Australia
    Posts
    2
    Rep Power
    0

    Similar problem


    Hi

    I've also got the same issue. I've created a ksh that uses sql+ to do select statements. It also works fine when executed from the prompt, but does not work when scheduled to run on cron.

    The sql in my script is like this:

    sqlplus -s USERNAME/PASSWORD@DATABASE <<END >$wsfile
    set heading off
    SELECT SQL QUERY HERE
    /
    END

    I've tried adding the oracle home to the script but this still does not help.

    Any assistance will be greatly appreciated.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Australia
    Posts
    2
    Rep Power
    0
    I found the solution.
    I had to include:

    export ORACLE_HOME=/ora/product/v9203

    Also to define the full path for the sql path.

    /ora/product/v9203/bin/sqlplus -s user/password@database
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    USA
    Posts
    334
    Rep Power
    11
    Whenever creating scripts run by cron, always

    - include full paths to all necessary executables
    i.e. /usr/bin/cat and so on.

    - define all necessary environmental variables.
    and export same.

    Do not assume that cron runs the script in your
    environment. It does not.

    - Finnbarr

IMN logo majestic logo threadwatch logo seochat tools logo