When a script is running with the forever module and you "forever list", you get a list with the filenames of all currently running scripts. In this case, "myscript1.js"
[0] j2mo /usr/local/bin/node myscript1.js 51004 51005 /Users/me/.forever/j2mo.log 0:14:10:51.420
[1] Vav3 /usr/local/bin/node myscript1.js 51011 51012 /Users/me/.forever/Vav3.log 0:14:10:21.221
Is there a way to get also the path to all running scripts?
We can get the path of the present script in node. js by using __dirname and __filename module scope variables. __dirname: It returns the directory name of the current module in which the current script is located. __filename: It returns the file name of the current module.
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.
Node can tell you where in the file system it is working by using the _filename and _dirname variables. The _filename variable provides the absolute path to the file that is currently executing; _dirname provides the absolute path to the working directory where the file being executed is located.
Use this to add directory column in the output
forever columns add dir
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With