crontab to remove email from a mailbox every 24 hrs?

estado3

Member
May 12, 2006
15
0
151
what is a simple cron tab to remove every 24 hrs emails in a mailbox called
mailbox on path /.neomail/mailbox ?

thanks
 

dragonbooster

Active Member
Oct 4, 2006
34
0
156
Following are the steps for setting up the cron to delete the mails from mailbox:

create the file emptymail box
cd /home/username/www
pico emptymailbox
type the following command in the file
echo > /home/username/path to mailbox
save your file
chmod 755
crontab -u username -e
set the following cron
0 0 * * * /home/username/www/emptymailbox
save the file

Please try this
 

designeru

Well-Known Member
Nov 2, 2005
83
0
156
... or a simpler solution...

add to /etc/crontab

0 0 * * * echo > /path_to_mailbox/
 

dragonbooster

Active Member
Oct 4, 2006
34
0
156
Thanks designneru and yufool for the simple solution.:)

Creating a separate file option can be use to set the multiple rules at one place so no need to set the different cron for each action
 

brianoz

Well-Known Member
Mar 13, 2004
1,146
7
168
Melbourne, Australia
cPanel Access Level
Root Administrator
If you're using maildir rather than the older mailbox, you'll need something like this:

find /.neomail/mailbox -type f -mtime +1 | xargs rm -f

which will remove all email older than 1 day, probably more what you want rather than just throwing it all out.

(Maildir email format stores mail as separate files, mailbox format stores mail concatenated all in one file)