The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
executing script by cron doesnt give me expected result anchal_khare UNIX for Advanced & Expert Users 1 09-12-2007 09:07 AM
Command doesn't work under cron ? bigjohn-nj Shell Programming and Scripting 4 01-20-2006 04:38 PM
script didn;t work in cron !!! @_@ stancwong Shell Programming and Scripting 2 10-04-2005 10:25 AM
ncopy doesn't work from cron Selma UNIX for Dummies Questions & Answers 2 01-20-2005 09:28 AM
Simple cron job won't work coregan UNIX for Dummies Questions & Answers 4 01-20-2004 05:22 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 09-12-2008
RoshniMehta RoshniMehta is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 3
Script doesn't work as expected when run on cron

The script checks for free space stats on Oracle. If there are any tablespaces with more than 85% usage it prints the details of the tablespace. If all the tablespaces have more than 15% free space, then "All tablespaces have more than 15 pct free space" must be printed on the screen.

When I run on the shell with ./scriptname it runs as described above. When I run it as a cron job, I do not get the message "All tablespaces have more than 15 pct free space"when all tablespaces have more than 15% free space.

I am pasting a part of the script:

# call Oracle script to query tablespace size
`sqlplus -S "/as sysdba" @/home/sidadm/script/dba_data_files.sql > .tmp1`
# call Oracle script to query freespace in tablespace
`sqlplus -S "/as sysdba" @/home/sidadm/script/dba_free_space.sql > .tmp2`
# paste them into a single file
paste .tmp1 .tmp2 |tail +4 > .tmp

# get the number of tablespaces
TS_CT=`cat .tmp | wc -l`

awk -v m=0 -v n=0 -v i="$TS_CT" '
{
# calculate freespace percentage
k =$3/$2*100;
# print the details if the percentage of freespace is less than 15
if($3/$2*100 < 15)
{
m = m + 1; # m keeps a count of number of tablespaces with freespace percentage less than 15
if(m==1) # print the heading (only once)
{
printf("%s \n","Tablespaces having less than 15pct freespace GB")
printf("%s \n","Tablespace Totalspace Freespace Freespace_pct")
}
len =length ($1)
printf("%s",$1)
for ( ;len < 30 ;len++)
{
printf("%c"," ");
}
len=length($2)
printf("%s",$2)
for ( ;len < 15 ;len++)
{
printf("%c"," ");
}
len = length($3);
printf("%s",$3)
for ( ;len < 15 ;len++)
{
printf("%c"," ");
}

printf("%f \n ",$3/$2*100);

}
else
{
n = n + 1; # n keeps a count of tablespaces with freespace percentage more than 15
if(n==i) # if all the tablespaces have free space more than 15 %
{
printf("%s \n","All tablespaces have more than 15 pct free space")
}
}

}

' .tmp >> $TOBREMAILED
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0