I know that you can find the working directory of a process a few different ways, but is there any way to do the reverse? I have some server applications written in node that are unfortunately tricky to tell apart as processes (they all show up as
node server.js in a
ps output) and I would like to have a simple way to determine whether or not a specific server was running.
In other words the question I need answered is; given directory
/x/y/z, is there a
node server.js process running with the working directory
Currently my best attempt is to do
ps -ef | grep "[n]ode server.js", cutting the PID and looping over them, checking
pwdx for each PID. It works, but it's cumbersome and I was wondering if there was a better way.