linux cron执行sh文件,Crontab-不同_ _.sh 文件执行方式

[oracle@ehtdb1 /home/oracle]$crontab -l28 16 * * * /home/oracle/test.sh

[oracle@ehtdb1 /home/oracle]$cat test.sh

export ORACLE_SID=HTDZ

export ORACLE_HOME=/ora/oracle/10.2

$ORACLE_HOME/bin/sqlplus sys/oracle as sysdba <

spool /home/oracle/testsql.log

select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

spool off

!

[oracle@ehtdb1 /home/oracle]$cat testsql.log

SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY

-------------------

2009-06-11 16:28:00

SQL> spool off

[oracle@ehtdb1 /home/oracle]$crontab -l

28 16 * * * /home/oracle/test.sh

以上内容,AIX 5.3测试成功

----------------------------------------------------------------------------------------

rw-r--r-- 1 oracle oinstall 503  6月 11 12:30 test.log

-rwxr-xr-x 1 oracle oinstall 124  6月 11 12:29 test.sh

-rw-r--r-- 1 oracle oinstall  25  6月 11 12:26 test.sql

[test.sh]

#!/bin/sh

source /home/oracle/.bash_profile

date >test.log

sqlplus sys/acsdb as sysdba @test.sql >>test.log

date >>test.log

[test.sql]

select * from dual;

exit

[test.log]

2009年  6月 11日 木曜日 12:30:22 CST

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 11 12:30:22 2009

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

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

D

-

X

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值