Hi Friends:
I have an weired situation here. I have written a small script to query number of sessions comming in from app servers to my database as well as to display the sar 5 5 report.
Here is my script.
connections.sql
Code:
select username, COUNT(*), status, machine
from v$session
where username is not null
and machine in ('xxxxxx','xxxxxx','xxxxxx')
and username ='xxxxxx'
GROUP BY USERNAME, status, machine
order by username asc, count(*) desc
/
spool off
!echo `sar 5 5 >> ics_connections.log`
!echo `cat ics_connections.log|mailx -s "SESSIONS and CPU" vijay.x.tummala@xxxxx.com`
exit
connections.sh
Code:
#!/usr/bin/ksh
. ~/.profile
sqlplus '/as sysdba' << EOF
@connections.sql
when i run connections.sh manually, it is executing fine and emailing me the below output.
HTML Code:
USERNAME COUNT(*) STATUS MACHINE
------------------------------ ---------- -------- -------------------------
XXXXX 1668 INACTIVE xxxxxxxx
XXXXX 1548 INACTIVE xxxxxxxx
XXXXX 1370 INACTIVE xxxxxxxx
XXXXX 14 ACTIVE xxxxxxxx
XXXXX 8 ACTIVE xxxxxxxx
XXXXX 2 ACTIVE xxxxxxxx
SunOS xxxxxx 5.10 Generic_125100-05 sun4u 12/15/2007
21:05:35 %usr %sys %wio %idle
21:05:41 15 9 0 75
21:05:47 15 8 0 77
21:05:53 15 8 0 77
21:05:59 14 7 0 79
21:06:05 14 7 0 79
Average 15 8 0 77
when i schedule the same thru crontab it is not working. Here is my cron entry.
Code:
Cron entry
15,30,45,00 * * * * /home/oracle/scripts/connections.sh > /dev/null 2>&1
Please help me to identify where i am going wrong.
Thank you,