By gkelly1117
#!/bin/ksh
#Author:Emmanuel Iroanya Jr
#Date:April 2nd, 2013
#Purpose: The purpose of this is to check data and rollout directory and keep file space optimal.
if [ "$1x" = "x" ]
then
echo "You must supply an environment parameter to this script"
echo "example: $0 tb82"
exit
fi
. /opt/origenate/$1/config/usrconfig.sh #Sources Environments Admin Config Variables
cd $ORDATA #Environments Data Storage Directory
du -sk * | sort -n -r | head -n 10 |awk '{print $2}' #Finds folder in Data Directory with most stuff in it.
cd $ORDATA/??? #I want to cd into Directory found with du -sk command above, what kind of loop do i Need? a for loop makes sense cant work out logic though?
cd backup #backup directory we save backup of files, big space issue offender
find *.zip -type f -a -mtime +3 -exec rm {} ;
find *.pdf -type f -a -mtime +3 -exec rm {} ;
find *.CSV -type f -a -mtime +3 -exec rm {} ;
find *.txt -type f -a -mtime +3 -exec rm {} ;
<br ...read more
Source: FULL ARTICLE at The UNIX and Linux Forums