免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3280 | 回复: 0
打印 上一主题 下一主题

AIX下配置DB2定时任务 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-01-21 00:21 |只看该作者 |倒序浏览
1. 编写sql脚本
   编写DB2需要执行的sql执行脚本,并存放到AIX服务器上。
   示例如下crontest.sql:
Sql代码
connect to tem user db2admin using db2admin;   
call P_TEST();  

connect to tem user db2admin using db2admin;
call P_TEST();
   
2. 编写sh执行文件
   编写sh文件,并存放到AIX服务器上,并修改sh文件为可执。
   示例如下crontest.sh:
C++代码
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucbHOME/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  

PATH=/usr/bin:/etc:/usr/sbin:/usr/ucbHOME/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文件中的变量直接复制过来。
C++代码
#修改sh文件的属性   
chmod 777 crontest.sh  

#修改sh文件的属性
chmod 777 crontest.sh
3. 配置crontab
    用db2admin用户登陆AIX系统,使用crontab –e命令进行定时任务设定。crontab的具体命令参见附注中的说明。
    示例如下:
C++代码
# 设置每天02:00分定时执行crontest.sh脚本   
00 02 * * * /home/db2admin/task/crontest.sh  

# 设置每天02:00分定时执行crontest.sh脚本
00 02 * * * /home/db2admin/task/crontest.sh

存盘退出即可。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP