Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2011
    Posts
    13

    Unanswered: Could not load module libdb2.a(shr.o)

    Apologies for such a noob question, but I've got a AIX server running DB2/AIX64 9.7.5. Whenever I run a program via cron, I'm getting:

    Code:
    Dependent module libdb2.a(shr.o) could not be loaded.
    Could not load module libdb2.a(shr.o).
    System error: No such file or directory
    I can work around it by first running a script which invokes db2profile and sets up a load of path and exports and then calls my perl program. How can I avoid this? There must be a better way.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by rnem170 View Post
    There must be a better way.
    Better in what respect? Set environment variables without setting environment variables?

  3. #3
    Join Date
    Nov 2011
    Posts
    13
    Quote Originally Posted by n_i View Post
    Better in what respect? Set environment variables without setting environment variables?
    better than always having to have a parent script to run everything else. I know I have to set them - but can't it be completely transparent? I tried calling .profile from the cron first, but that didn't work. In the end I had to have my kludge of a calling b.

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by rnem170 View Post
    I tried calling .profile from the cron first, but that didn't work.
    With that level of detail, I can only say it works for everyone I know.

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Nick is right. You can just do something like
    Code:
    source /home/db2inst1/.profile ; db2 connect to ... ; db2 drop table ... ; db2 terminate
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  6. #6
    Join Date
    Nov 2011
    Posts
    13
    does the db2 launching id have any bearing?

    there db2 stuff in ps -ef from root, db2as1, db2iggms, db2fenc1
    eg: /opt/IBM/db2/V9.7/bin/db2fmcd runs under root.

    my crontab entry is

    Code:
    00 * * * * /home/xresp/.profile ; /home/xresp/script/loader1.ksh
    loader1.ksh calls another script which then calls a program which loads data to tables

    .profile has in it:
    Code:
    # The following three lines have been added by UDB DB2.
    if [ -f /home/db2iccms/sqllib/db2profile ]; then
    . /home/db2iccms/sqllib/db2profile
    fi
    
    db2 connect to mydatabase
    when it runs, I get this:
    Code:
    Could not load program /home/xresdev/bin/DbBaseLoader2:
            Dependent module libdb2.a(shr.o) could not be loaded.
    Could not load module libdb2.a(shr.o).
    System error: No such file or directory
    If I remove .profile from cron and add the following into my loader1.ksh script:

    Code:
    . /home/db2iccms/sqllib/db2profile
    my script works

    so what's the difference?

    .. the 'weird' thing is that that I have another server (setup by a development group) on which I do not need to call db2profile at all. On that, my same script works perfectly with calling anything. (.profile or db2profile)

  7. #7
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Yes, of course the user matters. You probably don't want to run things as root. Either use a user-specific crontab or switch to a user with less privileges.

    As for your last question: you are not sourcing the .profile via
    Code:
    source .profile
    our
    Code:
    . .profile
    So what happens is that .profile is executed by starting a new shell. In that shell, the environment is set. Then the .profile execution completes, the shell is terminated and then your script comes in. But when the shell terminates, the changed environment settings in it are lost. That's normal behavior because a subprocess usually cannot influence the environment of its parent process.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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