Anmelden Seite Diskussion Versionen Go to the site toolbox

Vpopmail/delete files (emails) in the Trash folders that are older than x days

Aus CrazyLinux

delete files in the Trash folders that are older than x days, found on http://qtp.qmailtoaster.com/trac/browser/etc/cron.hourly/qtp-clean-trash


#!/bin/bash

# 09/11/09 - Eric <ejs@shubes.net>
# changed -ctime to -mtime
# refactored to simplify a bit
#
# 07/06/07 - Jake <jake@v2gnu.com>
# This is a modified version of Erik Espinoza's <espinoza@forcenetworks.com>
# qtp-prune.sh script. It has been modified to be used with the QmailToaster-Plus
# package.  It will delete files in the Trash folders that are older than 5
# days, and can be modified by adjusting the DELTIME variable.
#
# 23/10/2007 - Davide <buzzz@synhack.it>
# Added the possibility to use an external file to configure the deltrash value
# just put in DELTIME_FILE the path of the file which contain the value

# default DELTIME value
DELTIME=5

# config file for deltrash
DELTIME_FILE="/var/qmail/control/deltrash"

# see if there is a configuration file for DELTIME
if [ -e "$DELTIME_FILE" ] ; then
  DELTIME_TMP=`cat $DELTIME_FILE`
  if [ "$(echo $DELTIME_TMP | grep "^[[:digit:]]*$")" ] ; then
    DELTIME=$DELTIME_TMP
  fi
fi

# find and process each .Spam directory
# then find and process each file in the .Spam directory
# (this could probably all be done in a single find command)

for directory in $(find /home/vpopmail/domains -type d -name .Trash); do
  for file in $(find $directory -type f -mtime +$DELTIME); do
    rm -f ${file}  >/dev/null 2>&1
  done
done

Site Toolbox:

Meine Werkzeuge
Creative Commons-Lizenz
Diese Seite wurde zuletzt am 22. März 2010 um 22:19 Uhr geändert. - Diese Seite wurde bisher 146-mal abgerufen. - Impressum - Über CrazyLinux
Bienenwachskerzen Baumkerzenhalter