Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a forever process knowing the name

I have a node script in which I need to stop a forever process, before uploading the new version and restart it again;

the problem is that I only know the name of that process, and

forever stop processName.js

doesn't work, since it expect the index or the uid; is it possible to stop it knowing only the name?

like image 533
Cereal Killer Avatar asked Dec 16 '14 01:12

Cereal Killer


People also ask

What is npm forever?

What is forever? Forever is an npm module that ensures a Node. js script continuously runs in the background on the server. It's a helpful CLI tool for the production environment because it helps manage the Node applications and their processes.

How do I run a command in forever?

To start running a script with forever, use the forever start command, followed by the script name. You can run as many scripts as you need using forever . To check if there's any running forever process, run the forever list command. The forever process will be registered and keep running in the background.


2 Answers

Finally I got it, using a variable:

uid=$(forever list | grep processName.js | cut -c24-27) && forever stop $uid
like image 197
Cereal Killer Avatar answered Oct 23 '22 12:10

Cereal Killer


forever stop /home/user/server/script.js (full path)
like image 32
Yong-bin Jeong Avatar answered Oct 23 '22 13:10

Yong-bin Jeong