Dylan Harness
Dylan Harness

Reputation: 729

How to kill a process that restarts? (Forever)

I think I accidentally installed Foreverjs somewhere and started it. Every time I kill this process another one takes its place![enter image description here]1

I have no idea where forever might be (or if thats actually whats causing it) because I install it locally.

Upvotes: 1

Views: 5723

Answers (3)

Ian Samz
Ian Samz

Reputation: 2109

Turns out I had run the same script on PM2 on both a root user and of my new privileged user. The root user kept restarting the process with PM2 every time i killed it and its parent. So I did this

sudo su
pm2 status //to check pm2 processes
pm2 delete process_name //to delete the process
exit 
pm2 start "yarn start" --name process_name

Hope this helps save someone else's time

Upvotes: 1

Oskar Olofsson
Oskar Olofsson

Reputation: 36

If it restarts itself it means there is a parent process monitoring. Find the parent process and kill it first ps -o ppid= -p PID.

Upvotes: 2

Gntem
Gntem

Reputation: 7155

Take a look at Where does npm install packages? and npm folders documentation

Local install (default): puts stuff in ./node_modules of the current package root.

Global install (with -g): puts stuff in /usr/local or wherever node is installed.

run which forever to get the path where its installed and uninstall it with

  • forever stopall
  • npm uninstall forever if its globally installed add -g

Upvotes: 2

Related Questions