SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


Sidebar

Recently Changed Pages:

View All Pages


View All Tags


LinkedIn




WIKI Disclaimer: As with most other things on the Internet, the content on this wiki is not supported. It was contributed by me and is published “as is”. It has worked for me, and might work for you.
Also note that any view or statement expressed anywhere on this site are strictly mine and not the opinions or views of my employer.


Pages with comments

View All Comments

slesretention

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_ @ _getshifting.com
#
# 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_getshifting.com
# 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
You could leave a comment if you were logged in.
slesretention.txt · Last modified: 2021/09/24 00:25 (external edit)