2 years ago

Task scheduler works on homestead, but not on shared hosting

Posted 2 years ago by patrikw1

Hi, i have following methods in Kernel class:

     * Define the application's command schedule.
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
    protected function schedule(Schedule $schedule)

        //restarts queue worker, preventing memory stuck
                 ->name('restarts queue worker');

        //Each Video total_video_views will be accurately updated for example on daily basis.
                 ->between('9:00', '23:00')
                 ->name('updates all video views');

        //Page Insights will be updated
        $schedule->call(function () {
            $this->app->queue->push(new UpdatePageInsights);
                 ->name('page insights');

        //this is alternative to supervisor since shared hosting someties doesnt provide supervisor
        //so we use cron instead to keep queue worker up
        $schedule->command('queue:work --queue=high,default --memory=1024')
                 ->name('keeps queue worker active')

i run cron as: php web/artisan schedule:run

without & mark etc. When i set cron on the server and tell cron to mail me the output of the cron, i get excepted output with all those names i set on scheduled tasks..

However, none of these command get executed, i have no output in my lumen.log as i expected, and no new jobs in the database queue..

When i log on the server via SSH, and type php artisan schedule:run, it works, Lumen.log is filled with information and queue jobs are pushed to the default queue, and being processed.

Another strange thing is that, when i remove cron job from server, queue worker keeps processing jobs.. even though queue:work command is not executed by task scheduler anymore

Please can somebody explain me how is this possible?

Please sign in or create an account to participate in this conversation.