send_user_notifications (cron forum task)

Re: send_user_notifications (cron forum task)

by Benjamin Seclier -
Number of replies: 15
Hello Augusto,
Thank you for your help which saved us smile
Just a note : we can just use "admin/tool/task/cli/adhoc_task.php --execute" (specifying the task doesn't work).
Cheers.
Average of ratings: Useful (1)
In reply to Benjamin Seclier

Re: send_user_notifications (cron forum task)

by Dr. Nellie Deutsch -
What command should I add as I'm having the same problem all of a sudden with the forums? No one is getting notified by email.
In reply to Dr. Nellie Deutsch

Re: send_user_notifications (cron forum task)

by Augusto Villa -
Picture of Particularly helpful Moodlers

In order to "patch" (temporarily fix the problem) I did 2 things:

1) en /admin/settings.php?section=taskprocessing 


2) I programmed it to run every 5 minutes as well. 

With these two changes, the shipments did not double again ... But unfortunately the cron runs with a higher frequency than recommended.

I hope this can help you.

In reply to Augusto Villa

Re: send_user_notifications (cron forum task)

by Dr. Nellie Deutsch -
It may work. What do you have in your command line for your cron job?
In reply to Dr. Nellie Deutsch

Re: send_user_notifications (cron forum task)

by Augusto Villa -
Picture of Particularly helpful Moodlers

*/5 * * * *   /usr/bin/php /var/..../cron.php

In reply to Augusto Villa

Re: send_user_notifications (cron forum task)

by Dr. Nellie Deutsch -
Thank you. What do I add in the /.../
In reply to Dr. Nellie Deutsch

Re: send_user_notifications (cron forum task)

by Dr. Nellie Deutsch -

I want to thank you for all your help. I have 5-week 11 free online courses going on, now, so getting email notifications from the forums is very important to the the teachers and the participants. I'm kind of desperate, but with no funding to get professional help. 

I made the change in the file manager as stated, but don't  see any email notifications from the forums. Is there anything else I need to do?

In reply to Augusto Villa

Re: send_user_notifications (cron forum task)

by Dr. Nellie Deutsch -

This is what I see. Where do I add the changes?

                $task = new \mod_forum\task\send_user_digests();

                $task->set_userid($user->id);

                $task->set_component('mod_forum');

                $task->set_next_run_time($digesttime);

                \core\task\manager::reschedule_or_queue_adhoc_task($task);

                $usercounts['digests']++;

                $send = true;

In reply to Dr. Nellie Deutsch

Re: send_user_notifications (cron forum task)

by Dr. Nellie Deutsch -
$task = new \mod_forum\task\send_user_notifications();
$task->set_userid($user->id);
$task->set_component('mod_forum');
$task->set_next_run_time($digesttime);
\core\task\manager::reschedule_or_queue_adhoc_task($task);
$usercounts['digests']++;
$send = true;
In reply to Dr. Nellie Deutsch

Re: send_user_notifications (cron forum task)

by Augusto Villa -
Picture of Particularly helpful Moodlers
I'm sorry Nelli, all my comments from the other thread of this answer, aimed to correct a different problem than the one I now understand you have.

Could you please explain to us in more detail what is your situation?
In reply to Augusto Villa

Re: send_user_notifications (cron forum task)

by Dr. Nellie Deutsch -
I'm on Moodle 3.10. The upgrade went well and everything was working until it wasn't. 

Users do not receive email notifications from the discussion forums only. They receive email messages, badge notifications and so on, but not email notifications from the discussion forums.
In reply to Dr. Nellie Deutsch

Re: send_user_notifications (cron forum task)

by Benjamin Seclier -
Hello,
Can you show us what you see when you use the following command ?
/usr/bin/php /moodle_path/php/admin/tool/task/cli/adhoc_task.php --execute

This is the command that should send all notifications from forums (among other actions). Exemple :

Execute adhoc task: mod_forum\task\send_user_notifications
... started 07:26:02. Current memory use 40.6Mo.
Sending messages to student_login (269404)
Post 241357 sent
Sent 1 messages with 0 failures
Marking posts as read
Marked 1 posts as read
... used 23 dbqueries
... used 0.065815925598145 seconds
Adhoc task complete: mod_forum\task\send_user_notifications
Average of ratings: Useful (1)
In reply to Benjamin Seclier

Re: send_user_notifications (cron forum task)

by Dr. Nellie Deutsch -
Hi Benjamin,

Is this process new to Moodle V 3.10? I have never encountered the need for this command before. Do I add the command to under the account cron? This is what I have right now: /usr/local/bin/php /home/moodle4teachers/public_html/admin/cli/cron.php >/dev/null 2>&1 and it works for everything like badges, mail messages, course completion and so on.

This is what I got when I added your /usr/bin/php /moodle_path/php/admin/tool/task/cli/adhoc_task.php --execute

Cron <moodle4teachers@server> /usr/bin/php /moodle_path/php/admin/tool/task/cli/adhoc_task.php --execute

Status: 404 Not Found
Content-type: text/html; charset=UTF-8

No input file specified.

This is what I see under cron for forums

 $task = new \mod_forum\task\send_user_digests();
                $task->set_userid($user->id);
                $task->set_component('mod_forum');
                $task->set_next_run_time($digesttime);
                \core\task\manager::reschedule_or_queue_adhoc_task($task);
                $usercounts['digests']++;
                $send = true;
            }

            if (!empty($individualpostdata)) {
                $usercounts['messages'] += count($individualpostdata);

                $task = new \mod_forum\task\send_user_notifications();
                $task->set_userid($user->id);
                $task->set_custom_data($individualpostdata);
                $task->set_component('mod_forum');
                \core\task\manager::queue_adhoc_task($task);
                $counts['individuals']++;
                $send = true;
                
            }


In reply to Dr. Nellie Deutsch

Re: send_user_notifications (cron forum task)

by Dr. Nellie Deutsch -
\mod_forum\task\send_user_notifications
Ad hoc

Showing success but no email notifications are received.

I received this message when I did the cron job manually from the site:

Execute adhoc task: core_course\task\course_delete_modules
... started 05:29:55. Current memory use 3.7MB.
!!! Coding error detected, it must be fixed by a programmer: A lock was created but not released at:
[dirroot]/lib/cronlib.php on line 154

 Code should look like:

 $factory = \core\lock\lock_config::get_lock_factory('type');
 $lock = $factory-&gt;get_lock(ad639a871d90454e0b679d1c4569bfdc55160c17);
 $lock-&gt;release();  // Locks must ALWAYS be released like this.

In reply to Dr. Nellie Deutsch

Re: send_user_notifications (cron forum task)

by Augusto Villa -
Picture of Particularly helpful Moodlers
Hello nelli, can you please show us on the screen what each of the following executions throws at you by running them manually?
First:
#php admin/tool/task/cli/schedule_task.php --execute=\\mod_forum\\task\\cron_task
and later:
#php admin/tool/task/cli/adhoc_task.php --execute=\\mod_forum\\task\\send_user_notifications


Perhaps an alternative is in the task scheduler to temporarily stop that task that is generating an error. to see if when it runs again if it sends the regulations.