English 中文(简体)
这一说法能否等到外部进程结束?
原标题:Can this script wait for an external process to complete?

我已把这本手脚印作为JAR档案的包装。 该书在未经JAR等待完成其工作的情况下,便无问题地启动了JAR。

#!/bin/bash

export WORK=/opt/conversion
export LOG=$WORK
export XMAIL=me@email.com
export JAVA_BASE=/usr/java/jdk1.6.0_06
export JAVA_HOME=/usr/java/jdk1.6.0_06/bin
export JAR=$WORK/conversion.jar
export CLASSPATH=$JAVA_BASE/lib/tools.jar
export CLASSPATH=$CLASSPATH:$WORK/lib/ojdbc14.jar
export CLASSPATH=$CLASSPATH:$JAR

$JAVA_HOME/java -Xms256M -Xmx512M -classpath $CLASSPATH com.myapp.cam.conversion >>$WORK/job.out 2>&1 &

echo $! > $WORK/job.pid
mail -s "Conversion" $XMAIL < $WORK/user_message
exit 0

是否有办法等待我的联合调查组档案填写?

感谢您的投入。

最佳回答

页: 1

$JAVA_HOME/java -Xms256M -Xmx512M -classpath $CLASSPATH com.myapp.cam.conversion >>$WORK/job.out 2>&1 &

这使得它处于背景。

删除<代码>&,等待<代码>java程序,然后由您填写。

问题回答

正如其他人所说的那样,删除<代码>和>;和bash将等到指挥结束。 如果你坚持在这种背景下开展你的工作,你可以做些什么:

pid=`pidof java`

if [ "$pid" ]; then
    while kill -0 "$pid"; do
        sleep 1
    done
fi

<射线>()指令通常用于向特定过程发出信号,但作为信号,你仅检查是否存在无信号的这种假象程序。

如果你想在文字结尾处添加一个<代码>wait。

Don t在背景中管理着转换 Java的申请。 或者,在你看不见面之前,操作<代码>ps。 这将允许你在等待时做uff。





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...

热门标签