#!/bin/sh
programdir="."
program="test.py"
export CLASSPATH=$programdir
export LANG=zh_CN
startup()
{
res=`ps aux|grep python|grep $program|grep -v grep|awk '{print $2}'`
if [ -n "$res" ]
then
echo "$program already running"
else
nohup python $program > startup_out.file 2>&1 &
sleep 3
unset res
res=`ps aux|grep python|grep $program|grep -v grep|awk '{print $2}'`
if [ -n "$res" ]
then
echo " $program start success"
else
echo "$program start error"
fi
fi
}
shutdown()
{
proc_id=`ps aux|grep python|grep $program|grep -v grep|awk '{print $2}'`
if [ -n "$proc_id" ]
then
echo " $program is start,now kill......"
kill -9 $proc_id
echo " $proc kill ok !!!!!!!!!!!!!"
else
echo " $program is not start!!!!!!!!!!!"
fi
}
case "$1" in
start)
startup
;;
stop)
shutdown
;;
restart)
shutdown
startup
;;
*)
echo "Usage: {start|stop|restart}" >&2
exit 1
;;
esac
exit