问题描述:

I am trying to create a script that monitors a java runtime process,which makes use of a Virgo service. It should start the process when its not running. As there is no specific service name, i was thinking of grepping the name of the process and use it as an identifier.

Here is the code i thought of:

#!/bin/sh

service=virgo

ps auxw | grep $service | grep -v grep > /dev/null

if [ $? != 0 ]

then

/opt/apromore/ApromoreCode/build.xml start-virgo > /dev/null

else

echo Apromore is running already

fi

and this is the process I try to monitor (value from ps aux)

/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -classpath usr/share/ant/lib/ant-launcher.jar:/ usr/share/java/xmlParserAPIs.jar:/usr/share/java/xercesImpl.jar -Dant.home=/usr/ share/ant -Dant.library.dir=/usr/share/ant/lib org.apache.tools.ant.launch.Launc her -cp start-virgo

but even when the process is running, i cant identify it with the mentioned script. There is a error called $'\r'. I have no idea how to get rid of it.

相关阅读:
Top