1. jobgrid 监控的代码
#!/bin/sh
#detective the jobgrid
mkdir /etc/cron.jobgrid
echo "Copying the needed file..."
cp -rf ./lib /etc/cron.jobgrid > /dev/null
cp -rf ./etc /etc/cron.jobgrid > /dev/null
cp -rf ./logs /etc/cron.jobgrid > /dev/null
cp -f ./detective.sh /etc/cron.jobgrid > /dev/null
chmod 777 /etc/cron.jobgrid/detective.sh
echo "add the detective to /etc/crontab......"
echo -en "*/1 * * * * root run-parts /etc/cron.jobgrid >> /etc/cron.jobgrid/logs/jobgrid.log \n" >> /etc/crontab
echo "Congratulations......."
echo "execute cn.edu.jobgrid.tool.detective.Detective...."
java -cp /etc/cron.jobgrid/lib/classes12.jar:/etc/cron.jobgrid/lib/log4j-1.2.8.jar:/etc/cron.jobgrid/lib/mysql-connector-java-5.0.0-beta-bin.jar:/etc/cron.jobgrid/lib/detective.jar cn.edu.jobgrid.tool.detective.Detective
#detective the jobgrid
mkdir /etc/cron.jobgrid
echo "Copying the needed file..."
cp -rf ./lib /etc/cron.jobgrid > /dev/null
cp -rf ./etc /etc/cron.jobgrid > /dev/null
cp -rf ./logs /etc/cron.jobgrid > /dev/null
cp -f ./detective.sh /etc/cron.jobgrid > /dev/null
chmod 777 /etc/cron.jobgrid/detective.sh
echo "add the detective to /etc/crontab......"
echo -en "*/1 * * * * root run-parts /etc/cron.jobgrid >> /etc/cron.jobgrid/logs/jobgrid.log \n" >> /etc/crontab
echo "Congratulations......."
echo "execute cn.edu.jobgrid.tool.detective.Detective...."
java -cp /etc/cron.jobgrid/lib/classes12.jar:/etc/cron.jobgrid/lib/log4j-1.2.8.jar:/etc/cron.jobgrid/lib/mysql-connector-java-5.0.0-beta-bin.jar:/etc/cron.jobgrid/lib/detective.jar cn.edu.jobgrid.tool.detective.Detective
2. jobgrid中oracle的shell
#!/bin/sh -e
PID_FILE=/var/run/jobgrid.pid
case "$1" in
start)
if [ -f $PID_FILE ]
then
echo "monitor already started!"
exit 1
fi
echo $$ > $PID_FILE
./start-jobgrid&
;;
stop)
if [ -f $PID_FILE ]
then
PID=`cat $PID_FILE`
kill -TERM -$PID
echo "remove pid file"
rm -f $PID_FILE
else
echo "monitor already terminated!"
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
printf "Usage: $0 {start|stop|restart}\n" >&2
exit 1
;;
esac
exit 0
PID_FILE=/var/run/jobgrid.pid
case "$1" in
start)
if [ -f $PID_FILE ]
then
echo "monitor already started!"
exit 1
fi
echo $$ > $PID_FILE
./start-jobgrid&
;;
stop)
if [ -f $PID_FILE ]
then
PID=`cat $PID_FILE`
kill -TERM -$PID
echo "remove pid file"
rm -f $PID_FILE
else
echo "monitor already terminated!"
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
printf "Usage: $0 {start|stop|restart}\n" >&2
exit 1
;;
esac
exit 0
转载于:https://blog.51cto.com/amao99/224436