0% found this document useful (0 votes)
17 views6 pages

Medis Script

Uploaded by

Subrata Ray
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views6 pages

Medis Script

Uploaded by

Subrata Ray
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

#!

/bin/ksh

DIRECTORY_PATH=/medope01/med/app/oracle/orahome1/Apache/Apache/logs;

cd $DIRECTORY_PATH
if [ -d "$DIRECTORY_PATH" ]; then
echo " "
echo
"#############################################################################"
echo " LOG_DIRECTORY_PATH exists "
echo
"#############################################################################"
echo " WELCOME TO LOG_DIRECTORY_PATH "
echo
"#############################################################################"
echo " "
find . -type f -mtime +30 -name 'access_log*' -exec ls -l {} \; > access_log_list
Access_log_file=/medope01/med/app/oracle/orahome1/Apache/Apache/logs/
access_log_list
if [ -f "$Access_log_file" ] && [ -s "$Access_log_file" ]
then
echo " "
echo
"#############################################################################"
echo " Access_log files exists : - "
echo
"#############################################################################"
echo " "
echo " Access log files are archiving in progress "
echo " "
echo "....................................................."
echo " Please wait for moments "
echo " "
echo "......................................................"
find . -type f -mtime +30 -name 'access_log*' | xargs zip access_log.zip
> /dev/null 2>&1
if [ "$?" = "0" ]; then
echo " "
echo " Access_log files have archived succesfully : - "
echo ".............................................."
else
echo " "
echo "Access_log files were fail to archive succesfully : - "
echo "........................................................"
fi
find . -type f -mtime +30 -name 'access_log*' -exec ls -l
{} \; > access_log_list

Access_log_file=/medope01/med/app/oracle/orahome1/Apache/Apache/logs/
access_log_list
[ -f "$Access_log_file" ] && [ -s "$Access_log_file" ]
&& ls -l "$Access_log_file" > /dev/null 2>&1
if [ "$?" = "0" ]; then
find . -type f -mtime +30 -name 'access_log*' -exec rm
-r {} \; > /dev/null 2>&1

echo " Access_log files have deleted successfully "


rm "$Access_log_file"
echo " "
echo ".............................................."
else
echo "Access_log files were fail to delete
successfully : - "
rm "$Access_log_file"
echo
"..................................................."
fi
else
echo " "
echo
"#############################################################################"
echo " Access_log files do not exists : -"
echo
"#############################################################################"
fi

find . -type f -mtime +30 -name 'error_log*' -exec ls -l {} \; > error_log_list


Error_log_file=/medope01/med/app/oracle/orahome1/Apache/Apache/logs/
error_log_list
if [ -f "$Error_log_file" ] && [ -s "$Error_log_file" ]
then
echo
"#############################################################################"
echo " Error_log files exists : - "
echo
"#############################################################################"
echo " "
echo " Error log files are archiving in progress "
echo " "
echo "....................................................."
echo " Please wait for moments "
echo " "
echo "......................................................"
find . -type f -mtime +30 -name 'error_log*' | xargs zip error_log.zip
> /dev/null 2>&1
if [ "$?" = "0" ]; then
echo " "
echo "..................................................."
echo " Error_log files have archived succesfully : - "
echo " ..................................................."
else
echo " "
echo "....................................................."
echo " Error_log files were fail to archive succesfully : - "
echo "......................................................"
fi
find . -type f -mtime +30 -name 'error_log*' -exec ls -l {} \; >
error_log_list

Error_log_file=/medope01/med/app/oracle/orahome1/Apache/Apache/logs/error_log_list
[ -f "$Error_log_file" ] && [ -s "$Error_log_file" ] && ls -l
"$Error_log_file" > /dev/null 2>&1

echo " "


echo "......................................"
if [ "$?" = "0" ]; then
find . -type f -mtime +30 -name 'error_log*' -exec rm -r {} \; >
/dev/null 2>&1
echo " Error_log files have deleted successfully :- "
echo " "
echo "......................................."
echo " "
rm "$Error_log_file"
else
echo ".................................................."
echo " Error_log files were fail to delete successfully : - "
echo ".................................................."
rm "$Error_log_file"
fi
else
echo " "
echo
"#############################################################################"
echo " Error_log files do not exists :-"
echo
"#############################################################################"
echo " "
fi

find . -type f -mtime +30 -name 'frmweb_dump*' -exec ls -l {} \; >


frmweb_dump_list
Frmweb_dump_file=/medope01/med/app/oracle/orahome1/Apache/Apache/logs/
frmweb_dump_list
if [ -f "$Frmweb_dump_file" ] && [ -s "$Frmweb_dump_file" ]
then
echo " "
echo
"#############################################################################"
echo " frmweb_dump files exists : - "
echo
"#############################################################################"
echo " "
echo " frmweb_dump files are archiving in progress "
echo " "
echo "....................................................."
echo " Please wait for moments "
echo " "
find . -type f -mtime +30 -name 'frmweb_dump*' | xargs zip
frmweb_dump.zip > /dev/null 2>&1
if [ "$?" = "0" ]; then
echo " "
echo "................................................."
echo " "
echo " Frmweb_dump files have archived succesfully : - "
else
echo " Frmweb_dump files were fail to archive succesfully : -
"
fi
find . -type f -mtime +30 -name 'frmweb_dump*' -exec ls -l {} \; >
frmweb_dump_list

Frmweb_dump_file=/medope01/med/app/oracle/orahome1/Apache/Apache/logs/
frmweb_dump_list
[ -f "$Frmweb_dump_file" ] && [ -s "$Frmweb_dump_file" ] && ls
-l "$Frmweb_dump_file" > /dev/null 2>&1
if [ "$?" = "0" ]; then
echo " "
echo :..................................................."
find . -type f -mtime +30 -name 'frmweb_dump*' -exec rm -r
{} \; > /dev/null 2>&1
echo " "
echo :..................................................."
echo " Frmweb_dump file have deleted successfully :- "
rm "$Frmweb_dump_file"
else
echo " "
echo "..................................................."
echo " Frmweb_dump file were fail to delete successfully : - "
echo "..................................................."
rm "$Frmweb_dump_file"
fi
else
echo " "
echo
"#############################################################################"
echo " Frmweb_dump files do not exists"
echo
"#############################################################################"
fi
else
echo " "
echo
"#############################################################################"
echo " LOG_DIRECTORY_PATH has not exists :-"
echo " "
echo
"#############################################################################"
fi

DIRECTORY_PATH=/medope01/med/app/oracle/orahome1/Apache/Apache/logs;

cd $DIRECTORY_PATH
if [ -d "$DIRECTORY_PATH" ]; then
echo " "
echo
"#############################################################################"
echo " LOG_DIRECTORY_PATH has exists "
echo
"#############################################################################"
echo " WELCOME TO LOG_DIRECTORY_PATH "
echo
"#############################################################################"
echo " "

find . -type f -name 'access_log.zip' -exec ls -l {} \; > /dev/null 2>&1

echo
"#############################################################################"
echo " Access_log.zip is exists :-"
echo
"#############################################################################"
File_access_log=/medope01/med/app/oracle/orahome1/Apache/Apache/logs/access_log.zip
if [ -s "$File_access_log" ] && [ -f "$File_access_log" ]
then
echo " "
echo "........................................."
echo " access_log.zip file exist and not empty "
echo " "
echo "..........................................."
else
echo " "
echo "........................................."
echo " access_log.zip file does not exists and is empty "
echo "........................................."
fi

[ -f "$File_access_log" ] && ls -l "$File_access_log"


if [ "$?" = "0" ]; then
echo " "
suffix=`date +"%d%b%Y"`
filename=$File_access_log.$suffix
cp $File_access_log $filename
a=`basename $filename`
b=`echo $a | cut -d . -f1`
find . -type f -mtime +45 -name "$b*zip.?*" -exec
rm -r {} \;
echo "..........................................."
echo " access_log.zip file has deleted successfully."
else
echo " "
echo "..........................................."
echo " access_log.zip file has not deleted
successfully or nothing to delete "
echo "..........................................."
fi
find . -type f -name 'error_log.zip' -exec ls -l {} \; > /dev/null 2>&1
echo
"#############################################################################"
echo " Error_log.zip is exists :-"
echo
"#############################################################################"
File_error_log=/medope01/med/app/oracle/orahome1/Apache/Apache/logs/error_log.zip
if [ -s "$File_error_log" ] && [ -f "$File_error_log" ]
then
echo " "
echo "........................................."
echo " error_log.zip file exist and not empty "
else
echo " "
echo "........................................."
echo " error_log.zip file does not exists and is empty "
fi
[ -f "$File_error_log" ] && ls -l "$File_error_log"
if [ "$?" = "0" ]; then
echo " "
suffix=`date +"%d%b%Y"`
filename=$File_error_log.$suffix
cp $File_error_log $filename
a=`basename $filename`
c=`echo $a | cut -d . -f1`
find . -type f -mtime +45 -name "$c*zip.?*" -exec rm -r {} \;
echo "........................................."
echo " error_log.zip file has deleted successfully "
else
echo " "
echo "........................................."
echo " error_log.zip file has not deleted successfully or nothing to
delete "
fi
find . -type f -name 'frmweb_dump.zip' -exec ls -l {} \; > /dev/null 2>&1
File_frmweb_dump=/medope01/med/app/oracle/orahome1/Apache/Apache/logs/
frmweb_dump.zip
if [ -s "$File_frmweb_dump" ] && [ -f "$File_frmweb_dump" ]
then
echo " "
echo "........................................."
echo " frmweb_dump.zip file exist, or is not empty "
else
echo " "
echo "........................................."
echo " frmweb_dump.zip file does not exists and is empty "
echo " "
fi
[ -f "$File_frmweb_dump" ] && ls -l "$File_frmweb_dump"
if [ "$?" = "0" ]; then
echo " "
suffix=`date +"%d%b%Y"`
filename=$File_frmweb_dump.$suffix
cp $File_frmweb_dump $filename
a=`basename $filename`
e=`echo $a | cut -d . -f1`
find . -type f -mtime +45 -name "$e*zip.?*" -exec rm -r {} \;
echo "........................................."
echo " frmweb_dump.zip file has deleted successfully "
else
echo " "
echo "........................................."
echo " frmweb_dump.zip file has not deleted successfully or nothing
to delete "
fi

else
echo " LOG_DIRECTORY_PATH has not exists "
fi

You might also like