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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting The scripts not able to make the file to size 0, every times it go back to its original size
# 1  
Old 10-03-2010
The scripts not able to make the file to size 0, every times it go back to its original size

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

Last edited by mridul10_crj; 10-03-2010 at 07:57 AM.. Reason: not formated correctly
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find the original file size of encrypted file

Hi, I am trying to find out the original file size of an encrypted file in SunOS. The file was decrypted with gpg command. I want to know the size of the orginal file without decrypting it. I am using the below command, but it is not working for big files(more than 1 GB). gpg --passphrase... (4 Replies)
Discussion started by: vsachan
4 Replies

2. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

3. UNIX and Linux Applications

increase size of original KolourPaint object

I have a circuit drawing built with KolourPaint which when printed is about 1/5 the size at which it was drawn on the screen. Is there a secret squirrel trick to increase the size of the original by perhaps stretching the canvas or something like that without involving another application? (2 Replies)
Discussion started by: slak0
2 Replies

4. Shell Programming and Scripting

Get original file size of zipped file

Hi, I have a process which creates files and gzip all the files. Next day, i need to get the file sizes ( before zip size ) of all the gzipped files. Is there any way i can get the original file sizes of gzipped files. Gunzipping the files, getting the file size and gzipping again is not the... (6 Replies)
Discussion started by: forums123456
6 Replies

5. UNIX for Dummies Questions & Answers

How to know the Original size of the file without unzipping the File?

Hi, I don't have enough space on my Unix Box. So, I can't unzip the file and check the size of the file. So, I need to know, Is there any command, to check, how much the unzipped file takes after unzipping. Thanks in Advance. (4 Replies)
Discussion started by: Siva Sankar
4 Replies

6. Shell Programming and Scripting

Running Multiple scripts based on file size.

Hi, I have created 3 shell scripts which has to run one by one first two shell scripts will create a .txt files...which are used by the third shell script.Now I want to create a master script and run all these in a single script. Please give a pseudo code on how to so the same. ... (4 Replies)
Discussion started by: gaur.deepti
4 Replies

7. UNIX for Dummies Questions & Answers

swap memory and original size of HD

few questions a. where can I find the RAM of a server? im about to install redhat on a server (reformat). need to know because it will be my basis for swap size. i saw something line 3048MB detected upon boot. is this the memory? b. what is the command in lunux to check the original size of... (2 Replies)
Discussion started by: lhareigh890
2 Replies

8. Shell Programming and Scripting

Not able to make the file size 0 with the mentioned script

#!/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.... (3 Replies)
Discussion started by: mridul10_crj
3 Replies

9. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies
Login or Register to Ask a Question

Featured Tech Videos