SOLVED Cron To Remove Emails Older Than One Hour

wynonnal

Registered
Oct 23, 2017
2
0
1
California
cPanel Access Level
Root Administrator
I am currently using a cron script that scans a specific email address for a payment notification (this is for a membership website - the cron script is essential for sending emails and verifying membership status). The problem I am experiencing is that if there are too many emails in the inbox the script times out and does not complete its task.

The work around I am currently using removes any emails in the new and cur folders that are older than a day.

The cron script I have runs once a day and looks like this:
/bin/find /home/user/mail/domain/emailname/new ! -mtime -0 -type f -exec rm {} \;
/bin/find /home/user/mail/domain/emailname/cur! -mtime -0 -type f -exec rm {} \;

I need to narrow down the time criteria to remove any emails older than one hour.

I've look through older threads and on posts elsewhere and haven't found anything else that works.

Any suggestions?
 

jlucho

Well-Known Member
Aug 5, 2006
85
1
158
dear

add you script of clean , to :
/etc/cron.hourly
 
Last edited by a moderator:

sparek-3

Well-Known Member
Aug 10, 2002
2,045
230
368
cPanel Access Level
Root Administrator
You're looking for the -mmin parameter to find instead of -mtime.

You will have to specify in minutes, i.e. -mmin -60 for this to work
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,220
463
Hello,

I'm glad to see the previous posts helped. I've marked this thread as solved.

Thank you.