#!/bin/bash
# //----- (c) 2007 mk(a)adoptimize https://www.adoptimize.de
# //-----
# //----- für gewöhnlich sollte crontab -l diesen Job einmal am Tag aufrufen
# //----- loescht alle Dateien die aelter als 7 Tage sind
FILEPATH='/tmp/'
#DEFINE the ARRAY
DATEARRAY=();
# define the days
let DAYSBEVORE=7
# Fill with the date of today Datum (um Tage zurueckgerechnet) 3600sekundn, 24 Stunden, 7 Tage
KEYDATE=`perl -e '($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime (time); \
printf($mday);'`
DATEARRAY[$KEYDATE]="YES"
# gueltige Datumstage im Kalender sammeln
for DATEOFF in $(seq 1 $DAYSBEVORE); do
KEYDATE=`perl -e '($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime (time-(3600*24*'"$DATEOFF"')); \
printf($mday);'`
DATEARRAY[$KEYDATE]="YES"
# echo $KEYDATE;
done
#
#
for FILE in `ls -l --time-style=+"%e" $FILEPATH | awk '{print $6"|"$7}'`; do
# Strip the filename
FILENAME=`echo $FILE | sed s/^[[:digit:]]*\|//g`
# Strip the filedate with the Datenumber
FILEDAT=`echo $FILE | sed s/\|.*//g`
# SET REMOVE VARIBLE
if [ "${DATEARRAY[$FILEDAT]}" != "YES" ]; then
rm -f $FILEPATH$FILENAME
# echo "$FILEPATH$FILENAME -> $FILE DELFILE"
fi
done;
exit 0;
Zeichenerklärung |
||
| Hinweis: | ||
| Verweies innerhalb der Seite: | ||
| Link auf eine Erklärung im Detail: | ||
| Verweies auf eine andere Webseite: |
We optimize your success |
| ERP- & Marketing Software + Beratung |
| Google Adwords, Yahoo & Affiliates |