Report this

What is the reason for this report?

How to run artisan command in background Ubuntu 17.10

Posted on December 26, 2017

I am trying with putty below command and its working

php artisan horizon

But if I close ssh (putty) this command automatically shut down. with & command working in the background until I close putty.


php artisan horizon &

I want to run this command always in the background.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You need to use nohup utility to make it live after logging out.

nohup exec php artisan horizon

To ensure that php artisan horizon runs in the background even after you close your SSH session, you can use one of the following approaches:

1. Using nohup (No Hang Up):

nohup allows a process to continue running after the SSH session is closed.

nohup php artisan horizon > /dev/null 2>&1 &

This command sends the output to /dev/null, effectively discarding it. You can also redirect it to a file if you want to log the output:

nohup php artisan horizon > horizon.log 2>&1 &

2. Using screen:

screen allows you to run a process in a session that can be detached and reattached later.

  • Install screen (if not already installed):
sudo apt-get install screen
  • Start a new screen session:
screen -S horizon
  • Run your command:
php artisan horizon
  • Detach from the session by pressing Ctrl+A, then D. This will keep the process running in the background.

  • To reattach to the session:

screen -r horizon

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.