How to kill and stop uvicorn from respawning when running in the background (when started with nohup)

563 Views Asked by At

I started a fastapi app and uvicorn in the background with nohup as

nohup uvicorn main:app &

and it seems it runs as root in the background and if I kill it, it will soon respawn using kill -9 $(ps -efl | grep uvicorn | head -1 | awk '{print $4}'). Is there any way to kill or stop it without rebooting the server?

1

There are 1 best solutions below

0
Nathan Getachew On

You can try these alternatives.

pkill uvicorn

or

killall uvicorn

And with awk 'print $2'

kill -9 $(ps -efl | grep uvicorn | head -1 | awk '{print $2}')