search

Home  >  Q&A  >  body text

laravel scheduled task weekly

In laravel, we see weekly as a scheduled task,

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');

Does this mean that the specific time of the day of the week must be specified?
Or can I use weekly directly?
If I use weekly directly, which day of the week does it start?

伊谢尔伦伊谢尔伦2750 days ago740

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 16:54:28

    In the Event.php file:

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

    cron timing is 0 0 * * 0 *

    minute - an integer from 0 to 59
    hour - an integer from 0 to 23
    day - an integer from 1 to 31 (must be a valid day in the specified month)
    month - an integer from 1 to 12 (or as Jan or Feb abbreviated month)
    dayofweek - an integer from 0 to 7, 0 or 7 is used to describe Sunday (or expressed as Sun or Mon abbreviation)
    command - the command to be executed (can be used as ls /proc >> /tmp/proc or the command to execute a custom script)

    So weekly means execution at 0:00 every Sunday.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 16:54:28

    1. Weekly is executed at 0:00 every Sunday by default
    2. You can use it weeklyOn($day, $time = '0:0')
    3. There is no such problem

    reply
    0
  • Cancelreply