开发者

A shell script to read a text file and then run a java program

I have a java program that stops often due to errors which is logged in a .log file. What can be a simple shell script to detect a particular text line say

stream c开发者_如何学JAVAlosed

and then run the following command

java -jar xyz.jar


Here's a bash script to do something like that (may contain typos):

#!/bin/bash
tail -f logfile.txt | grep "stream closed" |
while read line
do
   java -jar xyz.jar
done


if grep 'stream closed' filename.log >/dev/null
then java -jar xyz.jar
fi


T1="`cat youfile.log  | grep 'stream closed'`"
if [ "$T1" = "stream closed" ]; then
   java -jar xyz.jar
fi
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜