当前位置:网站首页>laravel 定时任务
laravel 定时任务
2022-06-24 19:41:00 【王道长的编程之路】
一、自定义任务方法
php artisan make:command Task
二、自己生成的任务类
protected $signature = 'command:name';//执行任务的名称
public function handle()
{
/* * 这个方法做任务的具体处理,也就是对数据的操作,可用模型 例如我要删除用户表ID为1的用户 * */
DB::table('user')->where('id',1)->delete();
}
三、注册
# 去App\Console\kernel.php
protected $commands = [
//引入新创建的类
\App\Console\Commands\Task::class
];
protected function schedule(Schedule $schedule){
//此处相当于规定同意的定时执行时间,如每分钟分执行以下任务
// command('command:name')写的要与我们刚刚Task文件里的$signature相同
$schedule->command('command:name')->everyMinute();
}
四、运行
php artisan schedule:run
边栏推荐
- Servlet
- Research and investment strategy report on China's building steel structure anticorrosive coating industry (2022 Edition)
- [text data mining] Chinese named entity recognition: HMM model +bilstm_ CRF model (pytoch) [research and experimental analysis]
- 上新了,华为云开天aPaaS
- vulnhub Vegeta: 1
- 源码阅读 | OpenMesh读取文本格式stl的过程
- 【WSL】SSH 远程连接及宿主机端口转发配置
- Wechat side: what is consistent hash? In what scenario? What problems have been solved?
- 【Mongodb】READ_ME_TO_RECOVER_YOUR_DATA,数据库被恶意删除
- 2022年高压电工考试模拟100题及在线模拟考试
猜你喜欢

EPICS记录参考4--所有输入记录都有的字段和所有输出记录都有的字段

倍加福(P+F)R2000修改雷达IP

ACL (access control list) basic chapter - Super interesting learning network

ThreadLocal local thread

Wechat side: what is consistent hash? In what scenario? What problems have been solved?

Leetcode: calculate the number of elements less than the current element on the right (sortedlist+bisect\u left)
See how sparksql supports enterprise level data warehouse

Layer 2 and layer 3 forwarding principle based on VLAN

Dynamic menu, auto align

别再乱用了,这才是 @Validated 和 @Valid 的真正区别!!!
随机推荐
Database transaction Transanction
JWT(Json Web Token)
vulnhub Vegeta: 1
LeetCode Algorithm 剑指 Offer 52. 两个链表的第一个公共节点
Development specification - parameter verification exception, exception return prompt section
See how sparksql supports enterprise level data warehouse
Tech Talk 活动回顾|云原生 DevOps 的 Kubernetes 技巧
Learn more about the practical application of sentinel
C#学习两年的增删改查和C#导入导出(去重)案例
Sword finger offer 13 Range of motion of robot
环境配置 | VS2017配置OpenMesh源码和环境
Non single file component
「ARM 架构」是一种怎样的处理器架构?
Research Report on terahertz imaging system industry - market status analysis and development prospect forecast
Problem solving - nested lists
Common sense of resolution
花房集团二次IPO:成于花椒,困于花椒
cat写多行内容到文件
canvas 实现图片新增水印
Recommended course: workplace writing training