ITPub博客

首页 > Linux操作系统 > Linux操作系统 > HP Unix上oracle调用crontab报错

HP Unix上oracle调用crontab报错

原创 Linux操作系统 作者:yangtingkun 时间:2011-08-21 23:20:12 0 删除 编辑

Oracle用户的crontab可以运行,但是发现oracle用户无法对其进行修改。

 

 

尝试通过crontab –e的方式修改crontab的配置,在保存的时候报错:

/app/oracle10g/rman_catalog_dmp> crontab -l
40 14 * * * /app/oracle10g/rman_catalog_dmp/exp_by_date.sh
/app/oracle10g/rman_catalog_dmp> crontab -e
"/var/tmp/aaaa01943" 1 line, 59 characters
47 14 * * * /app/oracle10g/rman_catalog_dmp/exp_by_date.sh
~
~
~
~
"/var/tmp/aaaa01943" 1 line, 59 characters
crontab: can't create your crontab file in the crontab directory.
/app/oracle10g/rman_catalog_dmp> crontab -l
40 14 * * * /app/oracle10g/rman_catalog_dmp/exp_by_date.sh

建立一个crontab文件,采用crontab crontab_file的方式同样出现错误:

/app/oracle10g/rman_catalog_dmp> vi crontab.oracle
"crontab.oracle" 1 line, 59 characters
47 14 * * * /app/oracle10g/rman_catalog_dmp/exp_by_date.sh
~
~
"crontab.oracle" 1 line, 59 characters
/app/oracle10g/rman_catalog_dmp> crontab crontab.oracle
crontab: error in message queue open, errno=13
warning: commands will be executed using /usr/bin/sh

通过GOOGLE查询发现,这个问题有很多人碰到了,可惜的是,没有找到一个合理的解释也没有一个靠谱的解决方法。

由于在网上找不到解决方法,只好自己想办法解决,尝试使用root来设置oraclecrontab,结果这次没有报错,而且EXP脚本也成功运行了:

acap3#[/]crontab -e oracle
"/var/tmp/aaaa02394" 1 line, 59 characters
0 7 * * * /app/oracle10g/rman_catalog_dmp/exp_by_date.sh
~
~
~
~
"/var/tmp/aaaa02394" 1 line, 57 characters
warning: commands will be executed using /usr/bin/sh
acap3#[/]crontab -l oracle
0 7 * * * /app/oracle10g/rman_catalog_dmp/exp_by_date.sh

切换到oracle用户,在导出结束后收到mail通知:

/app/oracle10g/rman_catalog_dmp> more /app/oracle10g/rman_catalog_dmp/exp_by_date.sh
export ORACLE_SID=RMANDB
export ORACLE_BASE=/app/oracle10g
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export NLS_LANG=American_America.ZHS16CGB231280
export PATH=$ORACLE_HOME/bin:$PATH
DATE=`date +"%Y%m%d"`
exp parfile=/app/oracle10g/rman_catalog_dmp/exp.par file=/app/oracle10g/rman_catalog_dmp/rman_catalog_$DATE.dmp log=/app/oracle10g/rman_cat
alog_dmp/rman_catalog_$DATE.log
you have mail in /var/mail/oracle

> mail
From root@acap3 Thu Aug 18 15:21:46 EAT 2011
Received: (from root@localhost)
by acap3 (8.9.3 (PHNE_35950)/8.9.3) id PAA02370
for oracle; Thu, 18 Aug 2011 15:21:45 +0800 (EAT)
Date: Thu, 18 Aug 2011 15:21:45 +0800 (EAT)
From: root@acap3
Message-Id: <201108180721.PAA02370@acap3>
Subject: cron


Export: Release 10.2.0.4.0 - Production on Thu Aug 18 15:15:00 2011

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options
Export done in ZHS16CGB231280 character set and AL16UTF16 NCHAR character set

About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user RMAN_FGMS
. exporting foreign function library names for user RMAN_MODDB
. exporting foreign function library names for user RMAN_ACDB
.
.
.
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.


*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:

/app/oracle10g/rman_catalog_dmp/exp_by_date.sh


? q

这种办法虽然可以解决问题,但是同样也存在一个问题,就是oracle用户没有权限检查自己用户下的crontab设置了。

最后尝试在metalink中查询,没想到找到了最终的解决方案,文档参考ID 1005095.1。导致问题的原因是由于/usr/bin/crontab命令的权限不对:

acap3#[/]crontab -r oracle
acap3#[/]ls -l /usr/bin/crontab
-rwxrwxrwx 1 root bin 28672 Jul 18 2002 /usr/bin/crontab
acap3#[/]chmod 4555 /usr/bin/crontab
acap3#[/]ls -l /usr/bin/crontab
-r-sr-xr-x 1 root bin 28672 Jul 18 2002 /usr/bin/crontab

crontab命令的权限修改为4555后,oracle用户的crontab恢复正常:

/app/oracle10g/rman_catalog_dmp> crontab -e
"/var/tmp/aaaa02482"
# 0 0 * * * test.sh
~
~
~
"/var/tmp/aaaa02482" 1 line, 20 characters
warning: commands will be executed using /usr/bin/sh
/app/oracle10g/rman_catalog_dmp> more crontab.oracle
47 14 * * * /app/oracle10g/rman_catalog_dmp/exp_by_date.sh
/app/oracle10g/rman_catalog_dmp> echo "0 7 * * * /app/oracle10g/rman_catalog_dmp/exp_by_date.sh" > crontab.oracle
/app/oracle10g/rman_catalog_dmp> more crontab.oracle
0 7 * * * /app/oracle10g/rman_catalog_dmp/exp_by_date.sh
/app/oracle10g/rman_catalog_dmp> crontab crontab.oracle
warning: commands will be executed using /usr/bin/sh

从这个问题的解决过程也可以看出,Oraclemetalink知识库的强大之处,一个操作系统上的问题,在HP以及一些操作系统相关的专业网站上都查找不到,反而在Oraclemetalink中查询到了。

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/4227/viewspace-705514/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
暂无介绍

注册时间:2007-12-29

  • 博文量
    1955
  • 访问量
    10441407