PC: Если всё-таки будут запущены несколько процессов "JavaAgent", то будет лучше блок "status)" переписать так:
#!/bin/bash
#
PROGRAM="JavaAgent.jar"
JA_PID=/var/run/JavaAgent.pid
PROG_BIN="/usr/java/jre1.6.0_06/bin/java -Xmx128m -jar /home/notes/JavaAgent.jar"
PID=`ps -aef | grep "$PROGRAM" | grep -v grep | awk '{print $2}'`
case "$1" in
start)
if [ ! -z $PID ]
then
echo -n "Daemon JavaAgent is running"
echo ""
else
echo -n "Starting JavaAgent: "
echo ""
$PROG_BIN > /dev/null 2>&1 &
echo $! > $JA_PID
echo "Daemon JavaAgent started. PID:$!"
echo ""
fi
;;
stop)
echo -n "Shutting down JavaAgent: "
echo ""
for i in $PID; do
kill -9 $i
rm -f $JA_PID
done
echo -n "Daemon JavaAgent is down."
echo ""
;;
restart)
$0 stop
$0 start
;;
status)
STATUS=`ps -aef | grep "$PROGRAM" | grep -v grep | awk '{print $2}' | head -1`
if [ ! -z $STATUS ]
then
echo -n "Daemon JavaAgent is running"
echo ""
for i in $PID; do
echo PID:$i
done
echo ""
else
echo -n "Daemon JavaAgent is down."
echo ""
fi
;;
*)
echo "Usage: JavaAgent {start|stop|restart|status}"
exit 1
esac
exit 0