On my Linux server I have the following cron:
* * * * * php /var/www/core/v1/general-api/artisan schedule:run >> /dev/null 2>&1
The CRON works correctly. I have a scheduled command defined in my Kernel.php
as such:
protected function schedule(Schedule $schedule)
{
$schedule->command('pickup:save')
->dailyAt('01:00');
$schedule->command('queue:restart')->hourly();
}
The scheduled task at 1AM runs my custom command php artisan pickup:save
. The only thing this command does is dispatch a Job I have defined:
public function handle()
{
$job = (new SaveDailyPropertyPickup());
dispatch($job);
}
So this job is dispatched and since I am using the database driver for my Queues, a new row is inserted into the jobs
table.
Everything works perfectly up to here.
Since I need a queue listener to process the queue and since this queue listener has to run basically forever, I start the queue listener like this:
nohup php artisan queue:listen --tries=3 &
This will write all the logs from nohup
to a file called nohup.out
in my /home
directory
What happens is this: The first time, queue is processed and the code defined in the handle
function of my SaveDailyPropertyPickup
job is executed.
AFTER it is executed once, my queue listener just exits. When I check the logs nohup.out
, I can see the following error:
In Process.php line 1335:
The process "'/usr/bin/php7.1' 'artisan' queue:work '' --once --queue='default'
--delay=0 --memory=128 --sleep=3 --tries=3" exceeded the timeout of 60 seconds.
I checked this answer and it says to specify timeout as 0 when I start the queue listener but there are also answers not recommending this approach. I haven't tried it so I dont know if it will work in my situation.
Any recommendations for my current situation?
The Laravel version is 5.4
Thanks