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

prasadg's avatar

Setup cron job in cpanel

Hi, I have created one command which will add some record to mysql database.

When I execute command with terminal, command is adding data to database.

Then I have modified Kernel.php

protected $commands = [
        
		   \App\Console\Commands\AddData::class,
   ]; 
 protected function schedule(Schedule $schedule)
    {
		$schedule->command('word:add')->everyMinute();		
    }

I have setup cron job in CPanel.

Command Setting : Once per minute.

Command added as : /usr/local/bin/php /home/username/public_html/sitename/projectPath && php artisan schedule:run >> /dev/null 2>&1

But it is not adding row to database table. am I missing anything or I am doing something wrong with it?

0 likes
5 replies
prasadg's avatar

I checked for below command too, but it does not work.

* * * * * cd /home/hostcd1m/public_html/sitename/project-name && php artisan schedule:run >> /dev/null 2>&1

prasadg's avatar
prasadg
OP
Best Answer
Level 1

I have figure out the problem. for this case, we need to give path of artisan file, so the command would be

*   *   *   *   *   /usr/local/bin/php /home/username/public_html/sitename/projectPath/artisan schedule:run >> /dev/null 2>&1
bobbybouwmann's avatar

Yeah, indeed you don't need the cd part. The full path is fine as well ;)

1 like

Please or to participate in this conversation.