i wan to connect to an api and update some data in database every 20 seconds
so since i want to run it every 20 sec it gets a bit tricky with cronjob , i was wondering if i can use queue and jobs for this
i've created a job
php artisan make:job UpdateData
and put my code in the UpdateData handle , something like
public function handle()
{
$options = Option::all();
foreach ($options as $option)
{
$data = CURL($option->url );
$option->data = $data;
$option->save();
}
}
im new to queue and if i understand correctly , i need to create a queue table , call queue:work and dispatch this job somewhere in my code so the queue handles the job
but in this case , i just need to run this job every 20 seconds ... there is no dispatch basically i need a infinite loop with 20 sec sleep between them running in the background
so my question is , is this even possible ? if so how can i go about dispatching this job every x sec ... from command line ?