17

I just tried to automate the laravel process like(Start, Stop) in shell scripts. To start the laravel server, I use php artisan serve in the shell file.

I tried to stop the laravel server using command. But I was wonder, I didnt see any commands to stop the server. I used to Ctl+C to stop the server or to close the command prompt.

1.Any laravel commands to stop the server ?

  1. I have started the laravel server using shell file, which exits after starting.

How can I stop them now ? I dont have any command prompts running this process to exit the server.

miken32
  • 42,008
  • 16
  • 111
  • 154
Nandakumar
  • 1,071
  • 2
  • 11
  • 30
  • Locate the php process running artisan and kill it. If you are on windows system Ctrl + Shift + ESC => locate process => Right click => kill process – Tony Vincent Aug 04 '16 at 07:48
  • any other solutions tony vincent – Nandakumar Aug 04 '16 at 08:02
  • u can use something like php killall from the terminal – Tony Vincent Aug 04 '16 at 08:04
  • If you're running it on a port and you're running a 'nix system, you could do something like the following http://stackoverflow.com/questions/9168392/shell-script-to-kill-the-process-listening-on-port-3000 – Jonathan Aug 04 '16 at 19:48

3 Answers3

67

You can kill the port

sudo kill $(sudo lsof -t -i:port_number)

Like if it is running on 8000, you can do below

sudo kill $(sudo lsof -t -i:8000)

If above not worked (because frozen or unresponsive process may not respond), add parameter -9 to kill command like this:

sudo kill -9 $(sudo lsof -t -i:8000)
AnasSafi
  • 5,353
  • 1
  • 35
  • 38
sumit
  • 15,003
  • 12
  • 69
  • 110
6

Easier and you can view all processes about artisan :)

ps aux | grep artisan
# get the PID from the list
kill <PID NUMBER>
miken32
  • 42,008
  • 16
  • 111
  • 154
1

Try killall -9 php Then sudo kill $(sudo lsof -t -i:8000) Then php artisan serve