Sponsored Content
Top Forums Shell Programming and Scripting Not able to make the file size 0 with the mentioned script Post 302458469 by mridul10_crj on Friday 1st of October 2010 01:21:37 AM
Old 10-01-2010
Not able to make the file size 0 with the mentioned script

Code:
#!/bin/sh
##########################################################################################################
#This script is being used for AOK application for cleaning up the .out files and zip it under logs directory. 
# IBM
# Created 
#For pdocap201/pdoca202 .out files for AOK
#1. Send and zip the files from /usr/filenet/p8/domains/wlsdomain/
#2. Remove the copied files in /usr/filenet-out/archive
#3. Remove the .out file more than 750 MB
#
#
###########################################################################################################
# Define all date variables
###########################################################################################################
#
tempY=`date '+%Y'`
tempm=`date '+%m'`
tempb=`date '+%b'`
tempd=`date '+%d'`
tempH=`date '+%H'`
tempM=`date '+%M'`
tempS=`date '+%S'`
dt="Date${tempY}${tempm}${tempd}_Time${tempH}${tempM}${tempS}"
###########################################################################################################
# The destination file locations are variable so that it can be changed according to the file system provide.
###########################################################################################################
host_file_location1="/usr/filenet/p8/domains/wlsdomain/fnetServer1.out"
host_file_location2="/usr/filenet/p8/domains/wlsdomain/fnetServer3.out"
destination_file_location="/usr/filenet-out/archive"
logFile="/usr/filenet-out/logs"
 
 
report_filesize1=`ls -l ${host_file_location1} |awk '{print $5}'`
report_filesize2=`ls -l ${host_file_location2} |awk '{print $5}'`
cat ${logFile}/output.log_${dt}
##chmod 777 ${logFile}/output.log_${dt}
echo "filesize1_${report_filesize1}" >> ${logFile}/output.log_${dt} 
echo "filesize3_${report_filesize2}" >> ${logFile}/output.log_${dt}
flag_filesize=768000
echo "print file limit ${flag_filesize}" >> ${logFile}/output.log_${dt}
if [ $report_filesize1 -ge $flag_filesize ]
then
echo "inside if when fnetServer1.out is greater" >> ${logFile}/output.log_${dt}
echo "Coping the fnetServer1.out file to the ${destination_file_location}" >> ${logFile}/output.log_${dt}
cp -p ${host_file_location1} ${destination_file_location}/fnetServer1.out_${dt}
echo "Zip the old fnetServer1.out file to ${destination_file_location}" >> ${logFile}/output.log_${dt}
gzip ${destination_file_location}/fnetServer1.out_${dt}
echo "creating the fnetServer1.out file" >> ${logFile}/output.log_${dt}
cat /dev/null > ${host_file_location1}
echo "Archive of fnetServer1.out complete" >>${logFile}/output.log_${dt}
fi
if [ $report_filesize2 -ge $flag_filesize ]
then
echo "inside if when fnetServer3.out is greater" >> ${logFile}/output.log_${dt}
echo "Coping fnetServer3.out the file to the ${destination_file_location}" >> ${logFile}/output.log_${dt}
cp -p ${host_file_location2} ${destination_file_location}/fnetServer3.out_${dt}
echo "Zip the old fnetServer3.out file to ${destination_file_location}" >> ${logFile}/output.log_${dt}
gzip ${destination_file_location}/fnetServer3.out_${dt}
echo "creating the fnetServer3.out file" >> ${logFile}/output.log_${dt}
cat /dev/null > ${host_file_location2}
echo "Archive of fnetServer3.out complete" >>${logFile}/output.log_${dt}
fi 
#####################################################################################################
# Remove all files from the archive directory that are over 365 days old.
#####################################################################################################
#####################################################################################################
# remove the out files
#####################################################################################################
echo "Removing the out files older than 365 days" >> ${logFile}/output.log_${dt}
find ${destination_file_location}/*.gz -mtime +364 -exec rm -f {} \;
#####################################################################################################
# Removing the log files
#####################################################################################################
find ${destination_file_location}/logs/output.log_* -mtime +90 -exec rm -f {} \;
echo "End LogRemover.sh - `date`" >> ${logFile}/output.log_${dt}
echo "Console Logs have been redirected to output.log_${dt}" >> ${logFile}/output.log_${dt}

=================>>>>>>>>>>>>>>>>>>>>>>>
the file return back to its previous state after executing the file. e.g-- if the current file size is 1 GB and after executing the scriptthe file size is 0. but after some time again it return back to 1 GB. Need help.Smilie

Moderator's Comments:
Mod Comment Use code tags and maybe indention, thanks.

Last edited by zaxxon; 10-01-2010 at 02:34 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

The scripts not able to make the file to size 0, every times it go back to its original size

#!/bin/sh ########################################################################################################## #This script is being used for AOK application for cleaning up the .out files and zip it under logs directory. # IBM # Created #For pdocap201/pdoca202 .out files for AOK #1.... (0 Replies)
Discussion started by: mridul10_crj
0 Replies

2. Shell Programming and Scripting

How to write a script for the below mentioned issue

hello Forum members, I have a encrypted file which consist Unames and Pwd in the encrypted form and i have to write a script the PWD from the file and redirect into a log file.please find below the file and please help write a script. _config.id_dbs is the file which will open with a... (0 Replies)
Discussion started by: rajkumar_g
0 Replies

3. Shell Programming and Scripting

Script to read file size and send email only if size > 0.

Hi Experts, I have a script like $ORACLE_HOME/bin/sqlplus username/password # << ENDSQL set pagesize 0 trim on feedback off verify off echo off newp none timing off set serveroutput on set heading off spool Schemaerrtmp.txt select ' TIMESTAMP COMPUTER NAME ... (5 Replies)
Discussion started by: welldone
5 Replies

4. Shell Programming and Scripting

shell_script showing errors in the below mentioned script while executing in linux

code: IMAGE=$imgvalue; if then echo DO=ABC; elif then echo DO=ETC; elif then echo DO=XYZ; else echo "$imgvalue is unsupported"; exit 1; fi in above script IMAGE=1 , IMAGE=2, IMAGE=3 whatever may be the value i have assigned it's showing only DO=ABC other conditions... (7 Replies)
Discussion started by: saku
7 Replies

5. Shell Programming and Scripting

How to write bash shell script for mentioned requirement?

Hi All, I am unable to write the script for the below requirement. Requirement: Main table dir_ancillary table contain three column "dir_ancillary.table_name"," dir_ancillary.text_file_name ", "dir_ancillary.Include" . This dir_ancillary contain undefined tables in the column... (2 Replies)
Discussion started by: Vineeta Nigam
2 Replies

6. Shell Programming and Scripting

Extract data according to keys from filename mentioned in file

Hello experts, I want to join a file with files whosE names are mentioned in one of the columns of the same file. File 1 t1,a,b,file number 1 t1,a,c,file number 1 t2,c,d,file number 2 t2,c,e,file number 2 t2,c,f,file number 2 t2,c,g,file number 2 t3,e,f,file number 3 file number 1... (3 Replies)
Discussion started by: ritakadm
3 Replies

7. UNIX for Dummies Questions & Answers

How to modify the file mentioned in the Message details ?

i have a below file state : CONNECTED ; state : CONNECTED ; state : CONNECTED ; Rno : 5554f1d2-6f1b Rno : 10587563-4181 Rno : be6312f7-b4df the entire content in the fileis obtained by making two seperate Curl calls( one curl call gives me state when i grep the... (3 Replies)
Discussion started by: Vaibhav H
3 Replies

8. Shell Programming and Scripting

How to make script for file transfer?

Hi All, Please suggest me how to make script for file transfer from server X to another server Y. I have some directory path in server X as below: /home/directory_1/ . . /home/directory_n/ where some text files are available in each directory where some files records zero and some files... (6 Replies)
Discussion started by: aaditya321
6 Replies

9. Shell Programming and Scripting

How can I retrieve the matching records from data file mentioned?

XYZNA0000778800Z 16123000012300321000000008000000000000000 16124000012300322000000007000000000000000 17234000012300323000000005000000000000000 17345000012300324000000004000000000000000 17456000012300325000000003000000000000000 9 XYZNA0000778900Z 16123000012300321000000008000000000000000... (8 Replies)
Discussion started by: later_troy
8 Replies
All times are GMT -4. The time now is 09:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy