octobercms任务计划不起作用

编程入门 行业动态 更新时间:2024-10-15 12:38:29
本文介绍了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调用,例如 www.setcronjob

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

在带有路由的插件的根文件夹中创建一个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任务计划不起作用

本文发布于:2023-11-24 13:15:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1625346.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   计划   octobercms

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!