SHIFT

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

User Tools

Site Tools


slesretention
Differences

This shows you the differences between two versions of the page.

Link to this comparison view

slesretention [2013/05/14 20:53] (current)
sjoerd created
Line 1: Line 1:
 += Script: Bash: Sles Retention =
 +This is a simple retention script used on SLES. It can be easily modified to add directories for cleanup.
  
 +<code bash>
 +#!/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
 +</​code>​
 +
 +{{tag>​scripts linux}}
slesretention.txt ยท Last modified: 2013/05/14 20:53 by sjoerd