#!/bin/bash
#

if [ `whoami` != "root" ] ; then
	echo "Permission denied!"
	exit
fi

OUTFILE=`date +"%Y-%m-%d-%H:%M:%S"`

#program name
SERVICE_NAME=billing
PID_OF_PROG=`pidof $SERVICE_NAME`
if [ "$PID_OF_PROG" != "" ] ; then
echo -n "$SERVICE_NAME is already running, pid=$PID_OF_PROG!"
echo ""
else
cd /usr/local/agt/billing/bin
LOG_FILE="/var/log/billing.$OUTFILE.log"
./billing > $LOG_FILE 2>&1 &
echo -n "$SERVICE_NAME start success..."
echo ""
fi

crontab -u root /usr/local/agt/tools/cronset
