I have a moodle that has been incorrectly set up. i.e. the cron job has not run for a long time.
Having just upgraded the moodle to latest version 3.5.1 I intend to set the cron to run.
My concern is that this will cause a flood of old notifications, emails and messages to be sent that will now be received out of context given the time that has passed since they should have been sent.
Is there a way to purge these items before setting the cron to run.
Thanks in advance for your response.
No 'easy button' purge for things like forum postings, etc. :|
One would have to locate all DB tables related, inspect for dates, and relationships to 'importance' ... forums could be 'graded'. Lot's of DB work and one might 'purge' something that needed to be retained.
Would do this, however, in config.php add the following line:
$CFG->noemailever = true;
Something else to think about doing ... if you have SMTP setup and working to a mail server that relays, jot down the config settings. Then remove the settings ... basically telling Moodle to use PHPMailer.
If linux, install postfix ... PHPmailer will see and use postfix for sending the mail. Now the tricky part ... if the nomailever isn't set and cron job hits something that distributes mail ...
In one terminal window (call that session 'Killer') with prepared postfix scripts/commands to purge mail as messages are created and sent - or attempts to send.
The other terminal window actually running the cron via command line in moodlecode/admin/cli/.
Had to do something like the above (minus nomailever setting) for a site that had 10000 users forced subscribed to a forum and newbie Moodle Admin posted a message - then called to say there was a problem.
The 'Killer' session with many command repeats to purge messages before they were sent ... some had been sent and now bounces were coming back or mail deferred ... up arrow, enter ... when that finished, up arrow, enter, etc.. Sat there for about 15 minutes ... very boring ... server extremely slow ... but .... mission accomplished - eventually.
'spirit of sharing', Ken
Thanks Ken. Was that an older moodle version?
Howard: It seems like Ken suffered the issue that you say has been engineered out?
If you are *really interested...
// Posts older than 2 days will not be mailed. This is to avoid the problem where
// cron has not been running for a long time, and then suddenly people are flooded
// with mail from the past few weeks or months
$timenow = time();
$endtime = $timenow - $CFG->maxeditingtime;
$starttime = $endtime - 48 * 3600; // Two days earlier
Thanks Howard, much appreciated steer you provided there.
I'll go ahead and run the cron.
@Peter ... sigh! Yes it was ... a 2.7.highest - have been after them for years about upgrading but they are afraid of breaking their webservices automation.
And Howard is right ... Moodle Admin had posted to a forum so it was a situation where distribution had already begun and I was doing what I could to block any more going out and removing bounces as well.
'spirit of sharing', Ken