Answers.Body: <p>Craft 3 default action to run the queue is </p>
  
  <pre class="lang-php prettyprint-override"><code>public function actionRun(): Response
  {
      // Prep the response
      $response = Craft::$app-&gt;getResponse();
      $response-&gt;content = '1';
  
      // Make sure Craft is configured to run queues over the web
      if (!Craft::$app-&gt;getConfig()-&gt;getGeneral()-&gt;runQueueAutomatically) {
          return $response;
      }
  
      // Make sure the queue isn't already running, and there are waiting jobs
      $queue = Craft::$app-&gt;getQueue();
      if ($queue-&gt;getHasReservedJobs() || !$queue-&gt;getHasWaitingJobs()) {
          return $response;
      }
  
      // Attempt to close the connection if this is an Ajax request
      if (Craft::$app-&gt;getRequest()-&gt;getIsAjax()) {
          $response-&gt;sendAndClose();
      }
  
      // Run the queue
      $queue-&gt;run();
  
      return $response;
  }
  </code></pre>
  
  <p>So all you need is <code>Craft::$app-&gt;getQueue()-&gt;run()</code>. Every Craft 3 project comes with a default module so you can <a href="https://nystudio107.com/blog/enhancing-a-craft-cms-3-website-with-a-custom-module" rel="nofollow noreferrer">Enhancing a Craft CMS 3 Website with a Custom Module</a> or if <a href="https://nystudio107.com/blog/so-you-wanna-make-a-craft-3-plugin" rel="nofollow noreferrer">You Wanna Make a Craft 3 Plugin?</a> </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-31T10:27:09.677Z
Answers.Text: Thanks @Robin!
  This is extremely clear and helpful. Unless I am mis-reading this, I don't see how I would ever be able to call this just as an action by visiting example.com/actions/queue/run as I have to set the `runQueueAutomatically` config flag to false in order to prevent the queue from being run automatically, but the first thing this does is check that value is set to true. Seems very odd!
  However, since I can just call `Craft::$app->getQueue()->run()`, I can just make my own action for it instead.
Answers.UserDisplayName: Jai Redden
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-30T16:56:31.740Z
Answers.LastActivityDate: 2018-07-30T17:01:38.950Z
Answers.LastEditDate: 2018-07-30T17:01:38.950Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I have a task that I want to run, but unfortunately I dont seem to be able to disable mod_gzip/mod_deflate on this server, so that task will not run in the background and causes the site to hang while processing the task.</p>
  
  <p>Therefore, I have set the "runQueueAutomatically" config setting to false.</p>
  
  <p>I want to trigger the task queue to run manually (via a cron job), but I'm not sure how. In Craft CMS 2 I could visit "/index.php?p=actions/tasks/runPendingTasks" as per the docs here <a href="https://docs.craftcms.com/v2/config-settings.html#runtasksautomatically" rel="nofollow noreferrer">https://docs.craftcms.com/v2/config-settings.html#runtasksautomatically</a> but I can't find the same action for v3. Have gone through the docs and can't see it anywhere - can someone help?</p>
  
  <p>Thanks.</p>
  
Tags: <tasks>
Title: How to manually run pending tasks in Craft CMS 3
ThreadText: # How to manually run pending tasks in Craft CMS 3
  
  (Asked by: username_0 on 2018-07-30)
  
  I have a task that I want to run, but unfortunately I dont seem to be able to disable mod\_gzip/mod\_deflate on this server, so that task will not run in the background and causes the site to hang while processing the task.
  
  Therefore, I have set the "runQueueAutomatically" config setting to false.
  
  I want to trigger the task queue to run manually (via a cron job), but I'm not sure how. In Craft CMS 2 I could visit "/index.php?p=actions/tasks/runPendingTasks" as per the docs here <https://docs.craftcms.com/v2/config-settings.html#runtasksautomatically> but I can't find the same action for v3. Have gone through the docs and can't see it anywhere - can someone help?
  
  Thanks.
  
  **Tags:** tasks
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-07-30. Score: 3 | Accepted answer
  
  Craft 3 default action to run the queue is
  
  ```php
  public function actionRun(): Response
  {
      // Prep the response
      $response = Craft::$app->getResponse();
      $response->content = '1';
  
      // Make sure Craft is configured to run queues over the web
      if (!Craft::$app->getConfig()->getGeneral()->runQueueAutomatically) {
          return $response;
      }
  
      // Make sure the queue isn't already running, and there are waiting jobs
      $queue = Craft::$app->getQueue();
      if ($queue->getHasReservedJobs() || !$queue->getHasWaitingJobs()) {
          return $response;
      }
  
      // Attempt to close the connection if this is an Ajax request
      if (Craft::$app->getRequest()->getIsAjax()) {
          $response->sendAndClose();
      }
  
      // Run the queue
      $queue->run();
  
      return $response;
  }
  
  ```
  
  So all you need is `Craft::$app->getQueue()->run()`. Every Craft 3 project comes with a default module so you can [Enhancing a Craft CMS 3 Website with a Custom Module](https://nystudio107.com/blog/enhancing-a-craft-cms-3-website-with-a-custom-module) or if [You Wanna Make a Craft 3 Plugin?](https://nystudio107.com/blog/so-you-wanna-make-a-craft-3-plugin)
  
  > **Comments:**
  > **username_0**: Thanks @username_1! This is extremely clear and helpful. Unless I am mis-reading this, I don't see how I would ever be able to call this just as an action by visiting example.com/actions/queue/run as I have to set the `runQueueAutomatically` config flag to false in order to prevent the queue from being run automatically, but the first thing this does is check that value is set to true. Seems very odd! However, since I can just call `Craft::$app->getQueue()->run()`, I can just make my own action for it instead.  
  
  ---
  
  