Task
class Task (View source)
Constants
| MODE_CRON |
|
| MODE_INTERVAL |
|
| MODE_ONCE |
|
Methods
Create a Task instance
Schedule the task using crontab-like fields.
Schedule the task to run repeatedly every given number of seconds, counted from its last execution.
Shortcut for scheduling the task to run daily at a fixed time.
Marks this task to be dispatched as a detached background process instead of running synchronously within the scheduler process.
Whether this task should be dispatched as a detached background process
Configure the environments in which this task should be dispatched when the APP_ENVIRONMENT environment variable matches.
Executes the task's callback
Details
__construct(callable $callback)
Create a Task instance
Task
cron(int|string $minute, int|string $hour, int|string $day, int|string $month, int|string $weekday)
Schedule the task using crontab-like fields.
Note: Each field accepts: * (any), a single value, a comma-separated list (1,2,5),
a range (1-5), a step (*\/5 or 1-30/5), or a combination of these separated by commas.
Task
interval(int $seconds)
Schedule the task to run repeatedly every given number of seconds, counted from its last execution.
Task
once(DateTime $datetime)
Schedule the task to run exactly once, at (or after) the given date/time.
Once executed, it will never run again.
Task
at(int|string $hour, int|string $minute)
Shortcut for scheduling the task to run daily at a fixed time.
Equivalent to cron($minute, $hour, '*', '*', '*').
Task
runInBackground(bool $enable = true)
Marks this task to be dispatched as a detached background process instead of running synchronously within the scheduler process.
bool
isBackground()
Whether this task should be dispatched as a detached background process
Task
runInEnvironments(array $environments)
Configure the environments in which this task should be dispatched when the APP_ENVIRONMENT environment variable matches.
bool
isDue(DateTime $now, int|null $lastRun)
Checks whether the task is due to run now, given the last time it ran
int
run()
Executes the task's callback