[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