how to disable the process on a VPS after using

nohup node index.js & 
  • @Zow: What is your distribution used on VPS? Starting using nohup ( screen , dtach ) is a dtach crutch, and not a normal approach to starting daemons. Edit: found-noticed and rolled into your other question , which is closer to the topic. - drdaeman 2:32 pm

1 answer 1

Save the pid to a variable or file. Then kill.

You can get to the pid like this (contact immediately after calling nohup):

$$ - pid nohup

$! - pid node index.js

Kill process by pid - man kill

  • and without pid it is possible? - Zow
  • Well, you can write a shell that will run in the background index.js, and then kill when you need. But still it will be tied to the pid - gridsane
  • @gridsane, and if it doesn't turn right away, how can I find the pid now? - Zow
  • Get the pid of processes by name with arguments ps -eo pid, args | grep "PROCESS NAME WITH ARGUMENTS" | grep -v grep | cut -f2 -d "" - gridsane