task scheduling

task scheduling

by Kritika Sood -
Number of replies: 1

in my custom report plugin, i have a file cron.php in which i am emailing a user .

cron.php

function report_lastaccess_cron () {

 $a= email_to_user($user1, $user2, $subject, $messageText,$message);

}

when i run this script as site/admin/cron.php user recieves email.

now the question is i want to schedule this email.

For this i have create plugin/classes/task/send_email.php

email.php

namespace report_lastaccess\task;
class send_email extends \core\task\scheduled_task {     
    public function get_name() {
        // Shown in admin screens
        return get_string('email_send', 'report_lastaccess');
    }
                                                                    
    public function execute() {     

report_lastaccess_cron ();

}

}

i have also created plugin/db/tasks.php

tasks.php

$tasks = array(                                                                                                                    
    array(                                                                                                                         
        'classname' => 'report_lastaccess\task\send_email',                                                                           
        'blocking' => 0,                                                                                                           
        'minute' => '*',                                                                                                           
        'hour' => '*',                                                                                                             
        'day' => '*',                                                                                                              
        'dayofweek' => '*',                                                                                                        
        'month' => '*'                                                                                                             
    )
);

after running this i get a new entry in {task_scheduled} table

see attached image

but the task never runs and the entry last run in table is also empty.How can i run this task ?

Attachment localhost   localhost   totaradb   mdl_task_scheduled   phpMyAdmin 4.0.10deb1.png
Attachment Scheduled tasks.png
Average of ratings: -