My queue is working perfectly, when i run the following command php artisan queue:work
I’m using database as a QUEUE_DRIVER. On the server i don’t run the above command every-time.
for eg:
In schedule we have to run the command php artisan schedule:work. In this case on server we register this in cronetab like this:
* * * * * php /path/of/the/project/artisan schedule:run 1>> /dev/null 2>&1
Then we don’t have to run schedule work command again and again.
Is something also for queue. So we don’t have to run php artisan queue:work again and again. Also i don’t want to change the driver.
Related
The below cronjob is not working, although the task itself is working when I manually run it using php artisan q:calc .
I just added the path for php and artisan files as shown below, and pasted the command in the terminal.
Am I missing something ?
* * * * * /usr/bin/php /var/www/html/sharp/artisan schedule:run >> /dev/null 2>&1
That command is a cron entry, not something you run in terminal.
For example, under the specific user you would run (depending on your environment):
$ crontab -e
And paste the above to the crontab file.
You can learn more in the docs:
https://laravel.com/docs/master/scheduling
Or by researching how to add cron entries for your specific operating system.
Could you please share your best solution for run Laravel queue on production server?
For now I see next solution:
First start queue:
php artisan queue:work >> /var/log/queue.log &
Add to crontab:
10 2 * * * php artisan queue:restart
11 2 * * * php artisan queue:work >> /var/log/queue.log &
In case of project update on server:
php artisan down
php artisan queue:restart
#do update
php artisan queue:work >> /var/log/queue.log &
php artisan up
But I'm worrying about high load case. What if some job will be stucked?
Maybe you have better solution?
You can set up the laravel supervisor to run the queues automatically instead of using the cronjobs
Please find below the article for more details to run the queue automatically on the server without cronjob
Integration of Laravel Supervisor to process Queues
I have setup the follow Laravel Cronjob command:
protected function schedule(Schedule $schedule)
{
$schedule->command('DataDownloader:downloaddata')->dailyAt('19:34');
}
This saves some data from an API into a mySQL database. The command is listed under php artisan and I am able to run it using php artisan DataDownloader:downloaddata.
I have added the Cron entry to my crontab as per Laravel documentation:
* * * * * php /var/www/html/myprojectname/artisan schedule:run >> /dev/null 2>&1
When I run php artisan schedule:run it tells me 'No scheduled commands are ready to run'. I don't really know if this suggests if my Cronjob does not work at all or it is just broken.
Am I missing something or did I do something wrong that prevents the Cron from running?
My server is running Ubuntu with NGINX.
schedule:run command fires other commands that are ready to run at the time of its execution. So it means that in that exact time you ran it, no command was to be started.
However, you have defined cron that runs schedule:run every minute, thus when 19:34 comes, your command will be executed.
i have installed a Laravel package for dumping my database.
The plugin runs find, but i want to run it every day as a cronjob.
Here is the inserted command in Kernel.php:
$schedule->command('db:backup')->dailyAt('01:50');
Unfortunately it hasn't done anything.
Is it possible to run an artisan command direct in the Kernel.php without a Command class ?
Have you made sure to add the task to your system crontab? Typically located at /etc/crontab
* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
From https://laravel.com/docs/5.3/scheduling
PHP has no way of executing itself, so you need to set up a system task to call artisan every second, so laravel can evaluate the cron expressions and run them as needed.
I am using laravel 5.0.5 and I trying to run cron task on linux server.
I can manually run commands by ssh but I can't add command to cron task.
For example:
php artisan test_cron works correctly (insert record to DB) but
php artisan test_cron returns an error:
-bash: app: nie znaleziono polecenia (in English: command not found)
and
php artisan schedule:run - runs all commands once but
php artisan schedule:run 1>> /dev/null 2>&1 is not working
To add Laravel's scheduling command, firstly open up your crontab as follows:
crontab -e
Then add the following line changing the artisan path to where you have placed your site:
* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
Then hit save and you should have a message from the crontab:
crontab: installing new crontab
You should then confirm this by scheduling a task in Laravel to send you an email every 5 minutes or something.