octobercms任务计划不起作用

octobercms任务计划不起作用

本文介绍了octobercms任务计划不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于Laravel的OctoberCMS.

I'm using OctoberCMS based on Laravel.

我没有对服务器的SSH访问权限.

I don't have SSH access to my server.

每天我都需要删除一些在注册后24小时内仍未激活其帐户的用户,因此我正在考虑使用任务分配(例如cronjobs)

Each day I need to delete some users who haven't activated their account in 24 hours after registration, so I'am thinking about use a task sheduling ( like cronjobs)

根据octobercms docs 我应该制作一个用于注册任务调度的函数在自定义组件的Plugin.php中-我做到了.

According to octobercms docs I should make a function for register task sheduling in Custom Component's Plugin.php - I made it.

我使注册用户没有激活帐户,并且早于1天.

I made registered users without activation account and older then 1 day.

但是问题是-完全没有任何反应.

But problem is that - nothing is happening at all.

这是我在component.php中的代码:

It's my code in plugin.php of component:

public function registerSchedule($schedule)
{
    $schedule->call(function() {
        \DB::connection('mydb')->table('u')->whereRaw('u.created_at <= NOW() - INTERVAL 1 DAY')->where('is_activated','=',0)->delete();
    })->everyMinute();
}

注意:我已经将-> daily()更改为-> everyMinute()进行测试.

Note:I have changed ->daily() on -> everyMinute() for testing it.

推荐答案

您可以在主机或服务中使用经典的HTTP调用,例如 https://www.setcronjob.com

You can use a classic HTTP call with your host or a service like https://www.setcronjob.com

在带有路由的插件的根文件夹中创建一个route.php文件:

Create a routes.php file in the root folder of the plugin with the route:

use Route;

Route::get('/yourprefix/delete_users', function () {
DB::connection('mydb')->table('u')->whereRaw('u.created_at <= NOW() - INTERVAL 1 DAY')->where('is_activated','=',0)->delete();
});

当然,您可以添加一些身份验证来保护它.

Of course, you can add some authentication to protect it.

这篇关于octobercms任务计划不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 01:14