gpt4 book ai didi

laravel - 从数据库配置 Laravel 调度器的时间

转载 作者:行者123 更新时间:2023-12-02 04:36:17 24 4
gpt4 key购买 nike

我有一个 Laravel 5.2 应用程序,我现在使用调度程序每 30 分钟运行一次脚本。但我想知道是否可以从数据库中检索那个时间,我希望管理员用户从网页配置那个时间,我在数据库中有这个字段。但我不太确定调度程序是否可以从数据库更新该时间,所以,可能吗?

此外,我设置了:->sendOutputTo("/var/www/html/laravelProject/public/output")

将输出保存在一个名为 output 的文件中,但即使执行 cron 似乎也不起作用,我检查了 cron 日志文件,那里只显示没有安装 MTA,但我不想对于发送电子邮件的时刻,我只想将输出保存在文件中,所以,我在那里缺少什么?

最佳答案

You can use when The when method may be used to limit the execution of a task based on the result of a given truth test.

 $schedule->command('yourcommand:execute')->everyMinutes()->when(function () {
if($timefromdb){
return true;
}
else{
return false;
}

});

https://laravel.com/docs/master/scheduling#schedule-frequency-options

关于laravel - 从数据库配置 Laravel 调度器的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42334127/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com