title: Laravel run artisan command every 5 seconds
body: <p>I am working with a system that sends me webhooks anytime a resource in that system changes. The webhook contains the id of the resource that was updated. For example, if someone edits product ID 1234 in this system, my server will receive an alert saying that product 1234 has changed.  Then I make a request to their API to fetch the newest data for product 1234 and save it to my system.</p>
  
  <p>I am building this process to work asynchronously. Meaning, every time I receive a webhook, I save the details to a database table that logs the ID of the resource.  I then have a <code>WebhookQueue</code> class that contains a <code>run()</code> method, which processes all of the queued requests and updates the appropriate products.  Here's the code from the <code>WebhookQueue</code> class:</p>
  
  <pre><code>public static function run()
  {
          //get request data
          $requests = WebhookRequest::select(
                          'webhook_type',
                          'object_ext_id',
                          'object_ext_type_id',
                          \DB::raw('max(created_at) as created_at')
                  )
                  -&gt;groupBy(['webhook_type', 'object_ext_id', 'object_ext_type_id'])
                  -&gt;get();
  
          foreach ($requests as $request) {
                  // Get the model for each request.
                  // Make sure the model is not currently syncing.
                  // Sync the model.
                  // Delete all webhook request of the same type that were created before created_at on the request
                  if ($request-&gt;webhook_type == 'product') {
                          $model = Product::where([
                                          'ext_id'=&gt; $request-&gt;object_ext_id,
                                          'ext_type_id'=&gt; $request-&gt;object_ext_type_id
                                  ])-&gt;firstOrFail();
  
                          if (!$model-&gt;is_syncing) {
                                  $model-&gt;syncWithExternal();
  
                                  WebhookRequest::where([
                                          'webhook_type'=&gt;$request-&gt;webhook_type,
                                          'object_ext_id'=&gt;$request-&gt;object_ext_id,
                                          'object_ext_type_id'=&gt;$request-&gt;object_ext_type_id,
                                  ])
                                  -&gt;where('created_at', '&lt;=', $request-&gt;created_at)
                                  -&gt;delete();
                          }
                  }
          }
  }
  </code></pre>
  
  <p>I've also created a command that simply executes a line of code to process the queue. This command is <code>php artisan run-webhook-queue</code>.</p>
  
  <p>My plan was to run this command via a cron job every 5 seconds, but I have just come to learn that cron jobs can not be scheduled more granularly than by minute.</p>
  
  <p>How can I get this command to run every 5 seconds, or is there some other way I should be handling this scenario? I don't know anything about Laravel Queues, but it seems like I should be using that.</p>