Advertise on warmetal.nl!
Click for more information
about advertising here.

Did you find this website useful? Did I save you a lot of time?
Please consider donating to support this site:

 

Script: Bash: Sles Retention

This is a simple retention script used on SLES. It can be easily modified to add directories for cleanup.
#!/bin/bash
########################################################################################################################
# Author : Sjoerd Hooft
# Date Initial Version: 27 Jun 2011
# Comments: sjoerd_ @ _warmetal.nl
#
# Description:
# This is a default retention script for the /tmp directory on SLES linux servers.
#
# Recommendations:
# The script is designed for a 120 column terminal.
# The running user must be root.
#
# Changes:
# Please comment on your changes to the script (your name and email address, line number, description):
########################################################################################################################
 
# Script Variables
HOSTNAME_SHORT=`hostname -s`
BASEDIR=`dirname $0`
WHATAMI=`basename $0`
LOGFILE="$BASEDIR/$WHATAMI.log"
DATE=`date +%Y%m%d`
BOLD=`tput bold`
BOLDOFF=`tput sgr0`
TOMAIL=it_warmetal_nl
# Send all output to logfile
exec > $LOGFILE 2>&1
 
# Retention Variables
RETENTIONTIME=+7
TMP=/tmp
 
# Start Retention
find $TMP/. -mtime ${RETENTIONTIME} -print -exec rm -rf {} \; >> $LOGFILE
 
### MAIL Results
cat $LOGFILE | mail -s "Result Retention ${HOSTNAME_SHORT}" $TOMAIL
 
### End of Script
exit 0

Discussion

Enter your comment:
 
slesretention.txt · Last modified: 2012/01/06 09:30 by sjoerd