2

I have a page which supports some kind of mail notificiation. When user inserts some data, I want to send mail to another. I know, Mail::send() works perfectly, but it is slow. So I want to push this mail to queue. I use iron.io as provider. Everything works perfectly until I close console.

So is it possible to run php artisan queue:listen forever after I close console on Win and Linux?

Jozef Dúc
  • 965
  • 2
  • 18
  • 29

1 Answers1

10

You can run every process in the background in linux by using nohup

nohup php artisan queue:listen

This will keep the process running even if you close your terminal, nohup will force to ignore hangup signals.

nohup creates a logfile. If you want to suppress this, you can add

 >/dev/null 2>&1 &

after your command

baao
  • 71,625
  • 17
  • 143
  • 203
  • Thank you, this helped a lot, also with this answer http://stackoverflow.com/questions/24646320/nohupignoring-input-and-appending-output-to-nohup-out-in-linux-centos – Jozef Dúc Dec 13 '14 at 20:04
  • Consider monitoring this with something like `supervisord` too. – ceejayoz Dec 13 '14 at 20:06
  • You're welcome! You can ignore what nohup is telling you and close everything. You could build some kind of checkup if the process is still running, though it's quite reliable – baao Dec 13 '14 at 20:06
  • I do not have root user of cmd, so when I set `nohup` command and then close the terminal, the queue stops. The command or process is not running in background as expected. My question is, using non root user could be the issue here? – Himanshu Upadhyay Jul 04 '19 at 14:21
  • @HimanshuUpadhyay Feel free to ask a new question and make sure to include all the information about what you are doing so that people can help you – baao Jul 04 '19 at 15:17