Example from Laravel documentation:
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
DB::table('recent_users')->delete();
})->daily();
}
Notice the daily function.
I can't figure out , how will it find out at what time to start? Will it always start at midnight or at random floating time?
I tried to read the source code:
/**
* Schedule the event to run daily.
*
* @return $this
*/
public function daily()
{
return $this->spliceIntoPosition(1, 0)
->spliceIntoPosition(2, 0);
}
So I checked spliceIntoPosition function:
/**
* Splice the given value into the given position of the expression.
*
* @param int $position
* @param string $value
* @return $this
*/
protected function spliceIntoPosition($position, $value)
{
$segments = explode(' ', $this->expression);
$segments[$position - 1] = $value;
return $this->cron(implode(' ', $segments));
}
And eventually I got totally lost. Any ideas how it behaves?
daily()
, will the php script run daily at server timezone or at php timezone? (my server and php seem to have different timezones, and I dont plan on changing it). That is, if I use->delete()
withdailyAt("13:00")
, would the records be deleted at 13:00 server time or 13:00 php time? – Wimberly