2

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.

Chuck R.
  • 21
  • 1

1 Answers1

0

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 -:

ps auxW    # won't work
ps aux -W  # will probably do what you want

An alternative is

ps -efW

See e.g. the psgrep script that I wrote to kill lingering processes (such as Microsoft OneNote).

reinierpost
  • 8,425
  • 1
  • 38
  • 70
  • Thank you for your time. Although useful information, it still is not returning the process by using the java class name. I think I'm going to need to look into some alternative. Any other suggestions is welcomed. – Chuck R. Jul 24 '13 at 15:17
  • You're right - I should have verified that! I remember having seen a full command line in the past, but when I try it now, I do not get any arguments listed, either. – reinierpost Jul 24 '13 at 17:54