Informatica服务器定时删除Session log

shell脚本内容(设置保存一周):

#!/bin/bash

#Define house keeping works in B1  Informatica server Session Log
#Replace environment variable by PowerCenter
export INFA_HOME=/Informatica/10.2.0
export PATH=$INFA_HOME/server/bin:$PATH:.
export LD_LIBRARY_PATH=$INFA_HOME/server/bin:$LD_LIBRARY_PATH:.
export TIME_STYLE='+%Y%m%d %H:%M:%S'

#Clear Legacy Cache file in Informatica Cache Directory 
SHELL_HOME=/newinfa_data/prod/shell
LOG_FILE=$SHELL_HOME/rmsesslog_$(date +%Y%m%d).log

INFA_CACHE_DIR=/newinfa_data/infa_shared/SessLogs
CACHEFILE_KEEP_DAYS=$((7*24*3600))


#Time Stamp related
CURR_DATE=$(date +%s -d $(date +%Y%m%d))


ls -l $INFA_CACHE_DIR |grep -v  total   > $SHELL_HOME/cache_file_list.tmp

while read  filename_line
do
	#echo $filename_line

	filename=`echo $filename_line | awk '{print $8}'`	
	#echo $filename
	
	filedate=`echo $filename_line | awk '{print $6}'`
	file_timestamp=$(date +%s -d $filedate)	
	date_diff=`expr $CURR_DATE - $file_timestamp - $CACHEFILE_KEEP_DAYS`
	#echo $date_diff
	
	if [ $date_diff -gt 0 ];
	then
	
		echo $INFA_CACHE_DIR/$filename >>$LOG_FILE
		rm $INFA_CACHE_DIR/$filename	
	fi

done < $SHELL_HOME/cache_file_list.tmp

你可能感兴趣的:(服务器,linux,运维)