How to execute a specific scheduled task in shopware 6?

I want to execute a specific scheduled task. how to do it in shopware 6?

You may have a look at Setting up a scheduled task 

@Shopwareianer schrieb:

You may have a look at Setting up a scheduled task 

 

 

  1. I am using this command to run the task

php bin/console scheduled-task:run

I want to execute only my task

like  

php bin/console scheduled-task:delete_newsletter_recipient_task:run

How to do that?

  1. I have executed the command  

   php bin/console scheduled-task:run

  I have added some print_r() in my task. I want to see the print_r() when the task executed.

  but it is not showing the data. I have tried this command 

  php bin/console messenger:consume

  How to execute and debug my scheduled task?

I am also interested in testing the execution of a scheduled task for development purposes. Something like:

# This does not work - do not copy ;)
php src/bin/console scheduled-task:run --name shopware.sitemap_generate 

 

Hello, I would like to join in on this topic! Is there a possibility to execute only single tasks? Have you found a solution?

And if a task does not run, but is simply marked as „failed“ in the database - what is the best way to debug this? I have not found an error log anywhere.

Best regards, LA

You can check this table for ‚dead_message‘ for error messages

Or use the following plugin

You certainly found the solution in the meantime, but for the records, with the following command you can run a single scheduled task:

bin/console scheduled-task:run-single <taskName>

But in regards to debugging a failed job, I am also looking for help.

What I know so far:
When you can reproduce the bug in your local environment and you have Xdebug running, you can debug the task (let’s say shopware.sitemap_generate) by setting a breakpoint as usual and then running the single task as follows:

XDEBUG_SESSION=1 bin/console scheduled-task:run-single shopware.sitemap_generate

Review the log files might help. When Supervisor is running your scheduled tasks, there must be log files somewhere. By default they are located under $CWD/supervisord.log (see the Supervisor docs). Check the program definition for the actual location of your log files with cat /etc/supervisor.d/<nameOfYourScheduledTaskProgram>.conf.

I can strongly recommend the free FroshTools plugin which gives you a neat overview in your Shopware Administration. It allows you to comfortably run a specific task or change its interval or next execution time (see screenshots).