PHP JOB init.d Server

#!/bin/bash
# chkconfig 345 85 60
# description: startup script for php worker
# processname: worker

LDIR=/var/www/nginx-sites/site/httpdocs
EXEC=worker.php
PIDF=/var/run/worker.pid
IEXE=/etc/init.d/php_worker

### BEGIN INIT INFO
# Provides: worker
# Required-Start: $local_fs
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: startup script for php worker
# Description: startup script for php/worker.php which processes actionq into switch
### END INIT INFO

if [ ! -f $LDIR/$EXEC ]
then
        echo "PHP worker was not found at $LDIR/$EXEC"
        exit
fi

case "$1" in
  start)
        if [ -f $PIDF ]
        then
                echo "PHP worker is currently running. Killing running process..."
                $IEXE stop
        fi
        cd $LDIR;
        php $LDIR/$EXEC >> $LDIR/../log/carpot_worker.log & MYPID=$!
        echo $MYPID > $PIDF
        echo "PHP worker is now running."
        ;;
  stop)
        if [ -f $PIDF ]
        then
                echo "Stopping PHP worker."
                PID_2=`cat $PIDF`
                if [ ! -z "`ps -f -p $PID_2 | grep -v grep | grep 'worker'`" ]
                then
                        kill -9 $PID_2
                fi
                rm -f $PIDF
        else
                echo "PHP worker is not running, cannot stop it. Aborting now..."
        fi
        ;;
  force-reload|restart)
        $0 stop
        $0 start
        ;;
  *)
        echo "Use: $EXEC {start|stop|restart|force-reload}"
        exit 1
esac