skip to Main Content

I have this in my Kernal.php

$schedule->call(function () {
        DB::table('news')->delete();
    })->everyMinute();

when i do

php artisan schedule:run

it works fine.
But when i use cpanel and write in cron job

php /home/allnewsnepal/public_html/artisan schedule:run >> /dev/null 2>&1

the code doesnt run automatically.I dont have access to shell of cpanel.

2

Answers


  1. Chosen as BEST ANSWER

    Thanx for the help . I got my problem solved by doing

    php-cli -q /home/allnewsnepal/public_html/artisan schedule:run
    

  2. For cron’s in cPanel, you can look in this post:
    Run a PHP file in a cron job using CPanel

    The things that you should pay attention to are:

    1. Global path of your PHP (e.g. /usr/bin/php)
    2. Global path of your Laravel (e.g. /var/www/html/LaravelProjectName)

    In order to start a cron job on Linux based systems, you must specify the user for that cron, let’s say the user is root, so the cron job would look like this:

    root php /home/allnewsnepal/public_html/artisan schedule:run >> /dev/null 2>&1
    

    Of course with * prefixes depending on your cron schedule

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search