I am running a cron job, every 6 hours a day (6 AM, 12 PM, 6 PM, and 12 AM),
#!/usr/bin/ksh
......
$SQLPLUS / as sysdba <<!
@/home/oracle/scripts/daily.sql
!
cat /home/oracle/scripts/dbsizedaily.lst | mail -s "$TODAY: PROD DB Size" $RECIPIENTS
"@/home/oracle/scripts/daily.sql" has
spool /home/oracle/scripts/dbsizedaily append
select sum(bytes)/1024/1024/1024 "TOTAL_GB"
from dba_data_files;
select sum(bytes)/1024/1024/1024 "USED_GB"
from dba_segments;
spool off
exit
and it simply generates
TOTAL_GB
----------
3151.24316
USED_GB
----------
2330.40381
TOTAL_GB
----------
3151.24316
USED_GB
----------
2347.41551
TOTAL_GB
----------
3151.24316
USED_GB
----------
2349.76498
What I want to have out of the "@/home/oracle/scripts/daily.sql" is a tab delimeter file (to import into Excel better):
DATE TIME TOTAL_GB USED_GB %USED
3/5/2013 06:00 AM 3151.24316 2330.40381 73.95
3/5/2013 12:00 PM 3151.24316 2347.41551 74.49
3/5/2013 06:00 PM 3151.24316 2349.76498 74.56
.....
Please advise how to modify "@/home/oracle/scripts/daily.sql" or the ksh to get the output I want. If I can re-direct the output of spool /home/oracle/scripts/dbsizedaily append
to another file, that works for me.