Sponsored Content
Top Forums Shell Programming and Scripting Spool - Append and Calculation Post 302775593 by Daniel Gate on Tuesday 5th of March 2013 06:44:02 AM
Old 03-05-2013
Spool - Append and Calculation

I am running a cron job, every 6 hours a day (6 AM, 12 PM, 6 PM, and 12 AM),

Code:
#!/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

Code:
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

Code:
  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):

Code:
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.

Last edited by vbe; 03-05-2013 at 08:48 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Spool for Printer

i have created a new printer in the printcab file. when i use lpc and the status command it says: LMAPFE20: printer is on remote host lpt1: queuing is enabled printing is enabled cannot examine spool directory What ive... (1 Reply)
Discussion started by: JuergenW
1 Replies

2. UNIX for Dummies Questions & Answers

Spool

hi every body, is there any possibles to spool the commads with output(like oracle spool file) (1 Reply)
Discussion started by: kskumar
1 Replies

3. UNIX for Dummies Questions & Answers

Spool Issue

Hi: At every month end I would like to collect the information of a spool. Every Spool has more then one job, below is the individual job information, I really want to collect into a text file. Sp-id Proc User Printer Id Pty Form Copy Total SP7494 MONTHEND SYED R123 P2 1 WIDE ... (3 Replies)
Discussion started by: shah2
3 Replies

4. Shell Programming and Scripting

Spool / Spool off

Hi everyone I'm new in this forum, I have a question: I have a script with many sql staments and I have the spool command at the beginning and the 'spool off' at the end of the script. But, I want to write after each sql stament to a log file not at the end. How can I do it? Thanks (0 Replies)
Discussion started by: edzela
0 Replies

5. UNIX for Dummies Questions & Answers

Spool command in Unix

Hi, Is there any command in unix similar to spool command in oracle. (6 Replies)
Discussion started by: manosubsulo
6 Replies

6. Solaris

Spool directory

hi all, I have unix box I install 2 zone on it I want to make spool directory and assign one to each zone How can I do that ? (5 Replies)
Discussion started by: coxmanchester
5 Replies

7. UNIX for Dummies Questions & Answers

Like spool in UNIX

Hi, Can you please help me how to spool the unix commands executed in my client and its output to a file in local machine. Basically, I want to save all OS commands executed in my session and its output into a file from my client something like we do oracle with "SPOOL". Thanks in advance.... (2 Replies)
Discussion started by: pointers
2 Replies

8. UNIX for Dummies Questions & Answers

Issue with SPOOL

Hi, I use SunOS and i connect to database via isql. When tried using SPOOL command to extract the report from database, system thrown me saying "Spoool command not found". Please advise. (3 Replies)
Discussion started by: kusathy
3 Replies

9. Shell Programming and Scripting

Issues with SPOOL

I am using a unix shell script to create and then FTP the file to a mainframe application. The unix script uses spool to extract data from a Oracle database. The data is extracted into a text file. The text file is having all the data I need but not in the correct format. The rows of... (1 Reply)
Discussion started by: rameez
1 Replies

10. Shell Programming and Scripting

Append date to sql*plus spool (log) file in shell script

SQL*Plus version : 11.2.0.4 OS : Oracle Linux 6.5 SQL*Plus is a client application to connect to oracle database. The log file for this tool is generated via spool command as shown below. I am trying to append date ( $dateString ) to spool file as shown below. $ cat test2.sh #!/bin/bash... (4 Replies)
Discussion started by: kraljic
4 Replies
All times are GMT -4. The time now is 10:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy