Configure DB2 scheduled tasks in Linux

Source: Internet
Author: User

1. Write an SQL script

Compile the SQL Execution script that DB2 needs to execute and place it on the AIX server.

The following is an example of crontest. SQL:

  1. Connect ToTemUserDb2admin using db2admin;
  2. Call P_TEST ();

2. Write the sh execution File

Write the sh file and place it on the AIX server. Modify the sh file to be executable.

Example: crontest. sh:

  1. PATH =/usr/bin:/etc:/usr/sbin:/usr/ucb: $ HOME/bin:/usr/bin/X11:/sbin :.
  2. Export PATH
  3. If[-S"$ MAIL"] # This is at Shell startup. In normal
  4. Then echo"$ MAILMSG"# Operation, the Shell checks
  5. Fi # periodically.
  6. # The following three lines have been added by UDB DB2.
  7. If[-F/home/db2admin/das/dasprofile]; then
  8. ./Home/db2admin/das/dasprofile
  9. Fi
  10. # The following three lines have been added by UDB DB2.
  11. If[-F/home/db2admin/sqllib/db2profile]; then
  12. ./Home/db2admin/sqllib/db2profile
  13. Fi
  14. # Execute SQL script
  15. Db2-svtf/home/db2admin/task/crontest. SQL-z/home/db2admin/task/crontest. log

Note: The first part of the sh file is to set the environment variables required for db2 execution (required), which can be modified according to the actual situation or directly stored in db2admin. directly copy the variables in the profile file.

  1. # Modifying the attributes of the sh File
  2. Chmod 777 crontest. sh

3. Configure crontab

Use the db2admin user to log on to the AIX system and run the crontab-e command to set scheduled tasks. For more information about crontab commands, see the description in the notes.

Example:

  1. # Set to execute the crontest. sh script at every day
  2. 00 02 ***/home/db2admin/task/crontest. sh

Save the disk and exit.

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.