1. 编写sql脚本编写DB2需要执行的sql执行脚本,并存放到AIX服务器上。示例如下crontest.sql:
- connect to tem user db2admin using db2admin;
- call P_TEST();
2. 编写sh执行文件编写sh文件,并存放到AIX服务器上,并修改sh文件为可执。示例如下crontest.sh:
- PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.
- export PATH
- if [ -s "$MAIL" ] # This is at Shell startup. In normal
- then echo "$MAILMSG" # operation, the Shell checks
- fi # periodically.
- # The following three lines have been added by UDB DB2.
- if [ -f /home/db2admin/das/dasprofile ]; then
- ./home/db2admin/das/dasprofile
- fi
- # The following three lines have been added by UDB DB2.
- if [ -f /home/db2admin/sqllib/db2profile ]; then
- ./home/db2admin/sqllib/db2profile
- fi
-
- #execute sql script
- db2 -svtf /home/db2admin/task/crontest.sql -z /home/db2admin/task/crontest.log
注:sh文件的第一部分为设置db2执行需要的环境变量(必须设置),可以根据具体的实际情况进行修改,或直接将db2admin的.profile文件中的变量直接复制过来。
- #修改sh文件的属性
- chmod 777 crontest.sh
3. 配置crontab用db2admin用户登陆AIX系统,使用crontab –e命令进行定时任务设定。crontab的具体命令参见附注中的说明。示例如下:
- # 设置每天02:00分定时执行crontest.sh脚本
- 00 02 * * * /home/db2admin/task/crontest.sh
存盘退出即可。
MySQL多IDC部署注意事项Oracle 10g的RAC 在线日志也放在共享磁盘上相关资讯 DB2
- RHEL5 下安装 DB2 V9.7 数据库 (今 09:39)
- DB2常用脚本整理 (01月19日)
- Linux下DB2SQL1024N A database (01月12日)
| - DB2中REVERSE函数的实现 (01月19日)
- 使用 IBM Data Studio 创建和管理 (01月12日)
- TOAD连接DB2报错SQL1460N解决 (01月12日)
|
本文评论 查看全部评论 (0)