Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nkusibojoski's avatar

Why "php artisan schedule:run" is executing only first $schedule->call() function ?

I have written a crawler that is taking some data from a website, and I want to run it everyMinute, just to test it.

Here is code

protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        $crawler = new Crawler();
        $crawler->crawlVideos("someUrl",20);//20 is how many pages to crawl
    })->everyMinute();

    $schedule->call(function () {
        $crawler = new Crawler();
        $crawler->crawlImages("someUrl",20);//20 is how many pages to crawl
    })->everyMinute();

}

When I run php artisan schedule:run, it is crawling, it takes data and write them into DB, but ONLY from crawlVideos() function. If I change 20 to 2 or 3(how many pages to crawl), both functions are working, and I can see data in my DB.

Can someone tell me what is the problem ?

0 likes
4 replies
Snapey's avatar

i guess because by the time the first has run it's no longer time to run the second.

I don't know if this is a demo example but you could just run them both together in the same schedule?

nkusibojoski's avatar

Yes, I have tried and that way, putting both function in the same schedule,

$schedule->call(function () { $crawler = new Crawler(); $crawler->crawlImages("someUrl",20); $crawler->crawlVideos("someUrl",20); })->everyMinute();

but again the result is the same. First function is executed and I can see results in DB, and second isn't executed at all.

crawlImages() function is taking about less than 10 seconds.

I am wondering what it may be.

Snapey's avatar

have you looked in your laravel log file for clues?

Please or to participate in this conversation.