Topic: cronjob that deletes quarantined mails
==== Required information ====
- iRedMail version: 0.8.5
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): mysql
- Linux/BSD distribution name and version: Debian 7.3
- Related log if you're reporting an issue:
====
Hi,
i noticed the following problem with the cronjob that deletes the quarantined mails older than 15 days.
crontab of user amavis
# Delete virus mails which created 15 days ago.
1 5 * * * find /var/lib/amavis/virusmails/ -ctime +15 | xargs rm -rf {}
If i receive no infected mail for more than 15 days the cronjob also deleted the directory /var/lib/amavis/virusmails/.
After this quarantined mails are stored in a single file /var/lib/amavis/virusmails and not in a directory. And the cronjob results with an error that the directory does not exist.
My solution/workaround:
Because it is easier to change the modify date i do a touch on the directory first. And i use -mtime instead of -ctime.
# Delete virus mails which created 15 days ago.
1 5 * * * touch /var/lib/amavis/virusmails ; find /var/lib/amavis/virusmails/ -mtime +15 | xargs rm -rf {}
Cheers,
Stefan
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.