Search code examples
phplaravelcronschedule

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.


Solution

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