Results 1 to 5 of 5
  1. #1
    Join Date
    May 2003
    Posts
    369

    Unanswered: script not found when run on cron

    Hello folks,

    I have a DB2 ksh script running from a cron job and it fails to run correctly. We run it on AIX 5.2 32 bit using DB2 UDB 7.2 and receive the following error message:


    /home/script.ksh[64]: db2: not found.
    Interactive mode off.
    Local directory now /export
    257 "/export" is current directory.
    netout: write returned 0?
    netout: write returned 0?
    netout: write returned 0?


    ************************************************** ***************
    cron: The previous message is the standard output
    and standard error of one of the cron commands.

    Here is the crontab setup: to run every 15 minutes:


    # crontab -l
    00,15,30,45 03-20 * * * /home/script.ksh


    Funny thing is that when I run the db2 script manually it works fine without problems. How can I fix this to get it to run in cron? Thanks!

    Scott

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

    Re: script not found when run on cron

    Originally posted by mixxalot

    I have a DB2 ksh script running from a cron job and it fails to run correctly. We run it on AIX 5.2 32 bit using DB2 UDB 7.2 and receive the following error message:


    /home/script.ksh[64]: db2: not found.
    cron daemon does not execute the profile for you when it spawns a shell to run your script. As a result your DB2 environment (PATH, DB2INSTANCE, DB2COMM etc) is not set.

    You have to execute profile explicitly from your script before attempting to run db2
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Sep 2003
    Posts
    237
    Try # crontab -l
    00,15,30,45 03-20 * * * su - urnam -c "/home/script.ksh"
    where urnam is the userid with which you are able to run the script in interactive mode.This from the root's crontab. It switches to user urnam,
    establishing the right ENVironment; in particular PATH, and the DB2 variables.
    mota

  4. #4
    Join Date
    May 2003
    Posts
    369

    how do I configure the profile?

    Sorry my Unix sysadmin skills are rusty. How would I configure my profile settings for db2inst1 to run the cron job scheduled script ?

    Thanks!

    Scott

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

    Re: how do I configure the profile?

    Originally posted by mixxalot
    Sorry my Unix sysadmin skills are rusty. How would I configure my profile settings for db2inst1 to run the cron job scheduled script ?

    Thanks!

    Scott
    You should have the db2 profile settings in the standard user profile, /home/db2inst1/.profile in your case. You could insert the following into your script

    # check if db2 env. set
    if [ "$DBINSTANCE" = "" ]; then
    # not set; run profile
    . /home/db2inst1/.profile
    fi

    Alternatively, there should be a db2profile script in the instance's home directory. You could run it instead.
    ---
    "It does not work" is not a valid problem statement.

Posting Permissions

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