First of all Happy holidays to all of you.
I am trying to setup a Cron Job that would delete emails older than one month, but until now i was unsuccessful.
I was using this tutorial while i had my websites hosted on cPanel. And would like to know if that's okay also with KeyHelp or should i do it in another way.
I have posted it instead of pointing to the link.
[root@EcLinux]# touch mailcleaner.sh
Edit the file using your favorite file editor
[root@EcLinux]# vim mailcleaner.sh
find /home/username/mail/yourdomain.com/*/cur -type f -mtime +30 -exec rm -f {} \;
~
:wq
Then change that file to an executable one. (ie file permission to 755)
[root@EcLinux]# chmod 755 /root/mailcleaner.sh
Step 2 : Creating CRON job
Next step is to set the cronjob under root (for setting a cronjob refer this link). Here I’m setting the cron job to run every 1 day of the month.
[root@EcLinux]# crontab -e
0 0 1 * * /root/mailcleaner.sh > /dev/null 2>&1
:wq
[root@EcLinux]# crontab -l : To list all cronjobs.
In this case the file mailcleaner.sh will execute first day of every month and remove all emails older than 30days.
Credits for the tutorial goes to: Crybit