Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ubedthaheem's avatar

Artisan queue:work with cron job at shared hosting problem

Hello, this is my first thread / post in this forum.

In my application, there is a complex email sending system, one of them is: Job Seeker / Candidate applies on a job, the email is sent to employer with getting job & candidate data from more than 5 MySQL tables, the system checks and send emails

I used to send emails using jobs (QUEUE_CONNECTION=database), created a cron job to run artisan queue:work every 2 minutes, that works fine.. But the problem is, after few hours shared hosting crashes and throws 'too many mysql connections' error, and I received a warning to remove that cron job from system.

Now, what I do to solve that problem? the email flow is complexed, so it takes too much time to send email using QUEUE_CONNECTION=sync setting.

Here are cron job command:
/usr/local/bin/php -d memory_limit=512M /home/myuser/public_html/artisan queue:work --timeout=60 --tries=3 >> /home/myuser/cronjob.log 2>&1

/usr/local/bin/php /home/myuser/public_html/artisan queue:restart >> /home/myuser/cronjob.log 2>&1

0 likes
3 replies
tykus's avatar

You are creating a new queue worker process every two minutes; but, nothing is killing the previous processes?

Why is this not a scheduled job?

ubedthaheem's avatar

@Snapey Thank you for reply. Using cron job for scheduling in Laravel will not affect on performance and memory limit exceed error?

Please or to participate in this conversation.