Cron To Remove Emails Older Than One Hour
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?
-
dear add you script of clean, to : /etc/cron.hourly 0 -
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 0 -
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
This worked! Thank you so much - I did not have luck with mmin before but it was because I was setting the value to -0 but now that makes sense. Thank you again!0 -
Hello, I'm glad to see the previous posts helped. I've marked this thread as solved. Thank you. 0
Please sign in to leave a comment.
Comments
4 comments