- 论坛徽章:
- 3
|
脚本如下:
#!/bin/sh
sqlplus /nolog<<ENDOFINPUT
whenever sqlerror exit 20;
whenever oserror exit 20;
connect hxl/hxl;
variable cnt number;
begin
select Count(1) into :cnt from dual;
if :cnt = 0 then
:cnt:=0;
else
:cnt:=99;
end if;
end;
/
exit :cnt
ENDOFINPUT
flag=$?
echo $flag
手工执行没有问题
[etl@node1 shell]$ ./test.sh
SQL*Plus: Release 11.2.0.3.0 Production on Fri Mar 7 11:29:19 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> SQL> SQL> Connected.
SQL> SQL> 2 3 4 5 6 7 8 9
PL/SQL procedure successfully completed.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
99
[etl@node1 shell]$
[etl@node1 log]$ crontab -l
20 11 * * * /home/etl/shell/test.sh >>$HOME/log/output_test.log 2>&1
crontab中执行有问题,请问大家是什么原因?
[etl@node1 log]$ more output_test.log
/home/etl/shell/test.sh: line 2: sqlplus: command not found
127 |
|