Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2013
    Posts
    6

    Post Unanswered: db2 execute commands in parallel

    Hello All,

    I have a loop wherein I need to run each db2 commands in a new shell and put that process in background. I am using the following code inside a while loop

    ksh -c "db2 -tvf ${file}" &

    But, this is not executing as expected. Only one command is getting executed and the next command is waiting for the first command to complete.

    Please let me know on how to execute the db2 commands in parallel in a shell script


    Thanks in advance

  2. #2
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    What are the contents of ${file} - is it possible the parallel runs are waiting (e.g. due to locking, failure to commit..) etc. ?

  3. #3
    Join Date
    Oct 2013
    Posts
    6

    Post db2 execute commands in parallel

    The ${file} has just an export statement. There is no issue with locking, comit or wait because when I run it in two different shell manually it is working perfectly fine. But within a single shell it is not working.

    Thanks in advance.

  4. #4
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    Try creating a sub-script which does these things: (a) dots in the correct db2profile (b) connects to the database (aborting on failure), (c) perform the export to fully qualified pathname. Your sub-script can take command-line parameters (e.g. database-name, schema and table to export and the sql-query to run etc).

    Then in your parent script, use the backgrounding on this sub-script, supplying any parameters as needed.

  5. #5
    Join Date
    Oct 2013
    Posts
    6

    Smile db2 execute commands in parallel

    Thanks a lot db2mor, that worked well for me

Tags for this Thread

Posting Permissions

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