Search code examples
linuxbashlaravelqueuegnu-screen

Linux' Screen terminates without errors


I use Linux Screen to run some PHP script:

screen -L php artisan queue:work sqs --daemon --env=production

But unfortunately there is some error (in queue:work) and after 5-10 minutes Screen terminates immediately when an error occur. I don't see any error in screenlog.0. And because Screen terminates, it 'disappear' and I'm unable to read any output of php artisan queue:work. How do I make screen 'not' hide when it terminates (or may be some alternative approach)?


Solution

  • I found an answer:

    1. Run the screen command without any parameters
    2. When the command starts, you will see a virtual terminal. Then run your command: php artisan queue:work sqs --daemon --env=production
    3. Press Ctrl + A, D.

    Now when php... crashes, the screen command will be still running (what you can check by screen -ls and attach to the terminal by screen -r terminal_id. In my case, I see error Segmentation Fault and I change the command to: php artisan queue:listen sqs --env=production and now everything work good :)