Diego Cespedes
Diego Cespedes

Reputation: 1353

Laravel 5.2 - Scheduled Cron Job in Share Hosting

i created a scheduled for my post adds, after expire date change the visible to zero "false".

My kernel

$schedule->call(function () {

            foreach(Post::all() as $post)
                {
                    if(Carbon::now() > $post->expire_date){                          
                        $s = new Post;                        
                        $data = array(
                        'visible' => 0,
                        );
                        $s->where('id', '=', $post->id)->update($data);
                    }
                }
        })->everyMinute();

When i do in Local a command:

php artisan schedule:run

it work well! But IN MY HOSTIND IT DOEN'T WORK! i tryed to add a job to my share hosting like this:

php /home/dixardin/public_html/regalo/regalo/laravel/artisan schedule:run >> /dev/null 2>&1

The structure folder is like the picture: enter image description here

In my folder laravel i have the artisan file.

Upvotes: 1

Views: 1010

Answers (2)

Robin Dirksen
Robin Dirksen

Reputation: 3422

There can be two errors

  1. PHP Version
  2. Debug

  1. You can try to replace php with php70 in php /home/dixardin/public_html/regalo/regalo/laravel/artisan schedule:run >> /dev/null 2>&1. Maybe the webhost has php 7 (or another version) not renamed it to php.

  2. You can look in the debug what kind of error there's generated. php /home/dixardin/public_html/regalo/regalo/laravel/artisan schedule:run will be the new command.

Hope this works!

Upvotes: 1

Mahfuzul Alam
Mahfuzul Alam

Reputation: 3157

Try php-cli /home/dixardin/public_html/regalo/regalo/laravel/artisan schedule:run >> /dev/null 2>&1

Upvotes: 1

Related Questions