Laravel schedular: execute a command every second
<p>I have a project that needs to send notifications via WebSockets continuously. It should connect to a device that returns the overall status in string format. The system processes it and then sends notifications based on various conditions.</p>

<p>Since the scheduler can repeat a task as early as a minute, I need to find a way to execute the function every second.</p>

<p>Here is my <code>app/Console/Kernel.php</code>:</p>

<pre><code>&lt;?php    
  ...    
class Kernel extends ConsoleKernel
{
    ...
    protected function schedule(Schedule $schedule)
    {
        $schedule-&gt;call(function(){
            // connect to the device and process its response
        })-&gt;everyMinute();
    }
}
</code></pre>

<p>PS: If you have a better idea to handle the situation, please share your thoughts.</p>