Purging Mail Queue from Cron (2.7.x)

Purging Mail Queue from Cron (2.7.x)

by Scott Zuvich -
Number of replies: 8

I need to set up moodle cron on a system that was configured a while ago. Cron was not enabled when it was configured. There is about 6 months of backed up emails and notifications tied to cron that never went out. Is there a way to purge these before setting up cron so that mail only goes out starting now?

I have set up cron late in the game on a previous installation years ago and it unloaded a hellish backlog of emails to all users.

Average of ratings: -
In reply to Scott Zuvich

Re: Purging Mail Queue from Cron (2.7.x)

by Floyd Saner -

Scott,

The only way I know to do this is to directly edit the database and remove the back log of emails and notifications.  Someone who is server savvy might know of a way to prevent your mail utility from sending out the messages.

Floyd

In reply to Floyd Saner

Re: Purging Mail Queue from Cron (2.7.x)

by Scott Zuvich -

Do you imagine that altering the "last run" item for notifications and mailings in the Scheduled Tasks manager (in admin), for example: set last run to 'now', would cause the cron to skip everything scheduled prior to that?

In reply to Floyd Saner

Re: Purging Mail Queue from Cron (2.7.x)

by Scott Zuvich -

Alternatively, would you be able to point me to which tables I should be looking at in the database?

In reply to Floyd Saner

Re: Purging Mail Queue from Cron (2.7.x)

by Christopher Murad -

If you're running Linux based servers you can kill your mail transport agent service - run moodlecron a few times and then re-enable the service

That should ensure mail does not get processed.


Redhat based systems:


service exim stop


Debian:

/etc/init.d/exim stop


replace exim with sendmail or postfix or your fav. mta program.

Average of ratings: Useful (1)
In reply to Christopher Murad

Re: Purging Mail Queue from Cron (2.7.x)

by Scott Zuvich -

Windows Server w/ MS SQL. Mail is handled by an exchange server in a different department.

In reply to Christopher Murad

Re: Purging Mail Queue from Cron (2.7.x)

by Scott Zuvich -

From what you say, though, it sounds like I could configure smtp settings to point to any invalid server and run cron, yes?

In reply to Christopher Murad

Re: Purging Mail Queue from Cron (2.7.x)

by Ken Task -
Picture of Particularly helpful Moodlers

Just one more thing to check and empty ... depending if there are messages that couldn't be delivered and are in a mailq on the server.

On CentOS running Sendmail (adjust for theOS/MTA you have), the que is in /var/spool/mqueue/

Any file in there is pertaining to a message that couldn't be sent.   Remove them all:

from /var/spool/mqueue

rm -fR *

then list to see if there is anything in there: ls -l

Then restart the MTA daemon/process.

'spirit of sharing', Ken

Average of ratings: Useful (2)