I am working on modifying a shell script to work in Cygwin (paths, etc). One problem I am facing is with this particular line:
ps ax | grep -v grep | grep $DB_JAVA_CLASS > /dev/null 2>&1
Trying this with ps and procps, it does not seem to locate the process by the Java class name even though I know the process is running by evidence of /cygdrive/c/windows/system32/javaw showing from a manual ps ax/procps ax. I don't want to check for the java process itself in the event that more than one is running.
Is there some equivalent Cygwin method that can be used to obtain the same? Basically, the script is checking to see if the process is already running and if not, spawns the process.
Thank you for any insight you can provide.
I suppose your Java process is a standard Windows process rather than a Cygwin process; you need to add the
-W
flag to list those. Also be careful with the use of-
:An alternative is
See e.g. the psgrep script that I wrote to kill lingering processes (such as Microsoft OneNote).