source: etc/cron.hourly/qtp-clean-trash @ 3

Revision 3, 1.4 KB checked in by jake, 6 years ago (diff)

Brought up to date for new packages

  • Property svn:executable set to *
Line 
1#!/bin/bash
2
3# 07/06/07 - Jake <jake@v2gnu.com>
4# This is a modified version of Erik Espinoza's <espinoza@forcenetworks.com>
5# qtp-prune.sh script. It has been modified to be used with the QmailToaster-Plus
6# package.  It will delete files in the Trash folders that are older than 5
7# days, and can be modified by adjusting the DELTIME variable.
8#
9# 23/10/2007 - Davide <buzzz@synhack.it>
10# Added the possibility to use an external file to configure the deltrash value
11# just put in DELTIME_FILE the path of the file which contain the value
12
13# config file for deltrash
14DELTIME_FILE="/var/qmail/control/deltrash"
15
16# do not create the file DELTIME_FILE to use this value
17DELTIME=5
18
19if [ -e "${DELTIME_FILE}" ] ; then
20        DELTIME_TMP=`cat $DELTIME_FILE`
21
22        if [ "$(echo $DELTIME_TMP | grep "^[[:digit:]]*$")" ] ; then
23                DELTIME=$DELTIME_TMP
24        fi
25fi
26
27# Find Trash Dir
28PATH_TRASH="`find /home/vpopmail/domains -type d -name .Trash`"
29
30# Exit if no spam or trash directories found
31if [ -z "${PATH_TRASH}" ] ; then
32   exit 0
33fi
34
35# Delete Trash older than 5 days
36# if Trash directories found
37
38if [ -n "${PATH_TRASH}" ]; then
39        for each in "${PATH_TRASH}" ; do
40             FILES_TO_DELETE="`find ${each} -type f -ctime +$DELTIME`"
41             if [ -n "${FILES_TO_DELETE}" ]; then
42                for file in ${FILES_TO_DELETE} ; do
43                    if [ -n ${file} ]; then
44                       rm -f ${file}  >/dev/null 2>&1
45                    fi
46                done
47             fi
48        done
49fi
50
Note: See TracBrowser for help on using the repository browser.