首页 > laravel 定时任务 weekly

laravel 定时任务 weekly

laravel中定时任务看到有weekly,

These methods may be combined with additional constraints to create even more finely tuned schedules that only run on certain days of the week. For example, to schedule a command to run weekly on Monday:

$schedule->call(function () {
    // Runs once a week on Monday at 13:00...
})->weekly()->mondays()->at('13:00');

这里的意思是必须要指定每周哪天具体时间的吗?
还是可以直接用weekly?
如果直接用weekly的话又是这周哪天开始的呢?


Event.php文件中:

public function weekly()
{
   return $this->cron('0 0 * * 0 *');
}

cron定时是 0 0 * * 0 *

minute - 从0到59的整数
hour - 从0到23的整数
day - 从1到31的整数 (必须是指定月份的有效日期)
month - 从1到12的整数 (或如Jan或Feb简写的月份)
dayofweek - 从0到7的整数,0或7用来描述周日 (或用Sun或Mon简写来表示)
command - 需要执行的命令(可用as ls /proc >> /tmp/proc或 执行自定义脚本的命令)

所以weekly意思就是 每周日的0点0分执行。


1.weekly默认每周日的0点0分执行
2.你可用 weeklyOn($day, $time = '0:0')
3.就没有这个问题了

【热门文章】
【热门文章】