Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron Job in Laravel [duplicate]

I am trying to develop a cron job for a command I have already created. I am completely new to cron jobs so I dont really know how it works.

Trying the command by myself in the console works perfectly. All I need is to be able to execute it every 24 hours. I am using Laravel 4, can anyone help?

Thanks!

like image 269
Oliver Hoffman Avatar asked May 04 '13 12:05

Oliver Hoffman


2 Answers

To create a cron job as root, edit your cron file:

[sudo] crontab -e

Add a new line at the end, every line is a cron job:

25 10 * * * php /var/www/<siteName>/artisan <command:name> <parameters>

This will execute the same command at 10:25AM everyday.

Just make sure you keep a blank line after the last one. And you also might need to use the full path of your php client:

25 10 * * * /usr/local/bin/php /var/www/<siteName>/artisan <command:name> <parameters>
like image 183
Antonio Carlos Ribeiro Avatar answered Oct 28 '22 06:10

Antonio Carlos Ribeiro


You could register your cron job like this:

php /path/to/your/laravel/project/artisan your-custom-command
like image 28
Luis Dalmolin Avatar answered Oct 28 '22 08:10

Luis Dalmolin