Clear &PH& directory
-bash-3.2$ cat ClearPH.ksh
#!/bin/ksh
################################################################################
# File Name : ClearPH.ksh
# Description : Clears the &PH& directories of any files older than 10 days.
# This is a regular datastage maintenance task required as per:
# http://www-01.ibm.com/support/docview.wss?uId=swg21414210
#
# Change History
# Who When What
# ############### ########## #################################################
# Simon Vollett 11/11/2010 Original Version
################################################################################
function error_exit
{
echo “$1”
exit 1
}
DSHOME=`cat /.dshome`
export DSHOME
PATH=$PATH:$DSHOME/bin
export PATH
. $DSHOME/dsenv # set up DataStage environment variables
cd $DSHOME
#if [ “$?” = “0” ]; then
# . ./dsenv 2> /dev/null
#else
# error_exit “Cannot cd to $DSHOME. Aborting.”
#fi
# Get list of project installation directories for all datastage projects on this machine
for acctpath in $(${DSHOME}/bin/uvsh “LIST UV.ACCOUNT PATH FMT ‘100L’ ID.SUP HDR.SUP COL.SUP COUNT.SUP WITH PATH LIKE …/…” | sort | uniq | grep ‘/’ | grep -v $DSHOME)
do
DATE_TIME=`date +’%Y-%m-%d %H:%M:%S’`
phpath=”$acctpath/&PH&”
echo “$DATE_TIME: Clearing $phpath.”
# find and remove all files in &PH& directory older than 10 days excluding .uvnlsmap and base directory.
find ${phpath} -mtime +10 -a ! -name .uvnlsmap -a ! -type d -exec rm -f {} \;
if [ “$?” != “0” ]; then
error_exit “Problem clearing files from $phpath. Aborting.”
fi
done
exit 0