简体   繁体   English

修改Cygwin使用的Shell脚本

[英]Modifying Shell Script for Cygwin Usage

I am working on modifying a shell script to work in Cygwin (paths, etc). 我正在修改shell脚本以在Cygwin(路径等)中工作。 One problem I am facing is with this particular line: 我面临的一个问题是这条线:

ps ax | ps斧| grep -v grep | grep -v grep | grep $DB_JAVA_CLASS > /dev/null 2>&1 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. 尝试使用ps和procps进行操作,尽管我知道该进程正在通过手动ps ax / procps ax显示的/ cygdrive / c / windows / system32 / javaw的证据运行,但似乎无法通过Java类名称来定位该进程。 。 I don't want to check for the java process itself in the event that more than one is running. 如果有多个运行,我不想检查Java进程本身。

Is there some equivalent Cygwin method that can be used to obtain the same? 是否有一些等效的Cygwin方法可用于获得相同的结果? 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; 我想您的Java进程是标准的Windows进程,而不是Cygwin进程。 you need to add the -W flag to list those. 您需要添加-W标志以列出这些。 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 eg the psgrep script that I wrote to kill lingering processes (such as Microsoft OneNote). 请参阅例如我写的杀死残留进程的psgrep脚本(例如Microsoft OneNote)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM