0
0
Laravelframework~10 mins

Scheduler with cron in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to schedule a command to run every minute using Laravel's scheduler.

Laravel
protected function schedule(Schedule $schedule)
{
    $schedule->command('emails:send')->[1]();
}
Drag options to blanks, or click blank then click option'
Aweekly
Bdaily
Chourly
DeveryMinute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'daily()' instead of 'everyMinute()' will schedule the task once a day, not every minute.
2fill in blank
medium

Complete the code to schedule a closure to run daily at 13:00 (1 PM).

Laravel
protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        // Task code here
    })->[1]('13:00');
}
Drag options to blanks, or click blank then click option'
AweeklyOn
BdailyAt
CeveryMinute
Dhourly
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hourly()' will run the task every hour, not at a specific time.
3fill in blank
hard

Fix the error in the code to schedule a command to run every weekday at 8 AM.

Laravel
protected function schedule(Schedule $schedule)
{
    $schedule->command('report:generate')->[1]('8:00')->weekdays();
}
Drag options to blanks, or click blank then click option'
AdailyAt
BeveryMinute
ChourlyAt
DweeklyOn
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hourlyAt' is incorrect because it schedules tasks hourly, not daily.
4fill in blank
hard

Fill both blanks to schedule a command to run every Monday at 10:30 AM.

Laravel
protected function schedule(Schedule $schedule)
{
    $schedule->command('backup:run')->[1](1, '[2]');
}
Drag options to blanks, or click blank then click option'
AweeklyOn
BdailyAt
C10:30
D8:00
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'dailyAt' with two arguments causes an error.
Using wrong time format or wrong day number.
5fill in blank
hard

Fill all three blanks to schedule a closure to run every weekday at 7:15 AM and send output to a log file.

Laravel
protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        // Task code
    })->[1]('[2]')->weekdays()->[3]('/var/log/task.log');
}
Drag options to blanks, or click blank then click option'
AdailyAt
B07:15
CsendOutputTo
DeveryMinute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'everyMinute' instead of 'dailyAt' for scheduling.
Forgetting to specify the output file path.