Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2013
    Posts
    34

    Smile Unanswered: Problem while excuting the shell script

    Hello,

    I have written a shell script for backup of the database.

    When i run it, it is completing successfully. The script is with db2inst1 user

    But when i schedule the script through cron it gives error for db2 commands that "command not found"

    I got the cause behind this is cron is run by root user and due to this db2 command are executing with root user.

    Can anyone please help me the solution on this?

    Thanks in advance

  2. #2
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    This is a frequently asked question. Your script has to dot in the db2profile for the correct db2-instance because cron won't do that. Remember that you should never run normal db2 commands as root (except for install/update/upgrade/licence/instance-create/drop etc), instead run the script as an appropriate user.

  3. #3
    Join Date
    Sep 2013
    Posts
    34
    Hi ,

    In your reply you are saying "Your script has to dot in the db2profile for the correct db2-instance" means how exactly i have to call db2profile? On some environment i referred then i tried /home/instancename/.profile for this got error that no such file or directory. Can you please clarify how to create db2profile?

  4. #4
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    question is easily answered if you study the db2 documentation on-line ...

    You do not create db2profile, instead db2 creates that for you at instance-creation time, you simply have to dot it in.

    Example: Suppose your db2-instance account is called db2inst1

    At the start of your script (if it is a shell script for either bash or korn shell) :

    Code:
    . ~db2inst1/sqllib/db2profile

  5. #5
    Join Date
    Sep 2013
    Posts
    34
    Thanks a lot, it works

Posting Permissions

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