LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-08-2009, 11:26 AM   #1
Zealus.com
LQ Newbie
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2

Rep: Reputation: 0
Question Bash script to process mail queue


Hi all (my first post here)!

I look after a few CentOS servers, and since I am not a Linux guru some things get out of hand eventually. One of the things that has been bothering me for quite some time is mail queue.

On any average day I see around a hundred messages sitting in the queue, 99.99% of them are spam or bounces (mailbox doesn't exist, mailbox full, etc.) Some of these e-mails are sitting there for as long as few days (don't know if it affects the server, but it annoys the hell out of me). What I am looking for is either a setting or help on a bash script to rid of anything that sits there for longer then 48 hours. So far I have found that sendmail -bp lists all the e-mails in the queue but I don't really know how to parse it using bash.

Next part is /var/spool/exim/scan folder. I assume it's a part of the queue, therefore I am making it a part of the question. I see a bunch of files and folders going all the way back to 2007 (which is when the server was built). From the name I guess it's a temp folder for scanning incoming and outgoing e-mails so it has to get cleared once the scanning complete. Since it doesn't happen I would also appreciate a setting or help with a script that clears that out. Since the structure of this folder is pretty weird to me (it goes by numbers and letters of the alphabet in both cases, that in turn contain eml files) I am reluctant to just delete them since I suspect there's a database somewhere that keeps track of these things.

If you have an answer to any of these feel free to elaborate as much as possible - I'd rather read again something I already know than miss something I have no clue about.
 
Old 08-08-2009, 09:40 PM   #2
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Try looking into assassin this should help with your spam issue. You may also want to look into another product like barracuda which can help with spam also.
 
Old 08-08-2009, 11:28 PM   #3
Zealus.com
LQ Newbie
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jstephens84 View Post
Try looking into assassin this should help with your spam issue. You may also want to look into another product like barracuda which can help with spam also.
Hope you will not get offended if I point that your answer has nothing in common with what I was asking about. I do have SA running and it does its job well enough (although the strain on server gets so heavy that I am thinking about turning it off at least for some of the accounts.

My question(s) are mostly about settings and shell scripting, not about spam issues.

Thank you for understanding.
 
Old 08-08-2009, 11:43 PM   #4
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by Zealus.com View Post
Hope you will not get offended if I point that your answer has nothing in common with what I was asking about. I do have SA running and it does its job well enough (although the strain on server gets so heavy that I am thinking about turning it off at least for some of the accounts.

My question(s) are mostly about settings and shell scripting, not about spam issues.

Thank you for understanding.
None takin. I offered those as suggestions as to a solution that would stop spam before it even got to your server.

However yes you can use a shell script with cron and clean the folder up. I will try to cook something up and post back when I have something that works. Unless some one beats me.
 
Old 08-10-2009, 10:22 AM   #5
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Ok so I did find a starting point. if you used the command
Code:
find /var/log/mail -atime -2
it would search the /var/log/mail directory for anything older than two days. it will also go below any directory in mail so you may want to look here to stop going down the folder level.

http://linux.die.net/man/1/find

that should get you started.
 
  


Reply

Tags
bash, mail, sendmail



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
using the process status (ps) command in a bash script young_linux Programming 4 05-29-2009 11:13 AM
time a process within bash script aubrey-calm2 Linux - General 2 06-15-2007 01:39 PM
Bash script to check for dead process MaffooClock Other *NIX 12 05-18-2007 05:14 AM
Mail Queue Script keysorsoze Linux - Software 2 01-24-2007 12:31 PM
how do i kill a process from inside a bash script? mikaelo Programming 4 05-28-2004 08:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration