Trying to start a process on boot for Centos6, and am really struggling. If I have an error, will it be displayed on boot or is it logged somewhere? What am I doing wrong? Thank you
Code:
sudo chmod +x /etc/init.d/test_soap
sudo chkconfig --add test_soap
sudo chkconfig test_soap on
/etc/init.d/test_soap
Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides: Test SOAP Simulator
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start SOAP Simulator
# Description: Initiate a given PHP file every 5 seconds to simulate a SOAP server.
### END INIT INFO
SCRIPT= /usr/local/bin/test_soap
RUNAS=root
PIDFILE=/var/run/test_soap.pid
LOGFILE=/var/log/test_soap.log
start() {
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting service…' >&2
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping service…' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
status() {
if ps -p $$ > /dev/null
then
echo "$prog is running"
else
echo "$prog is not running"
fi
RETVAL=$?
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
/usr/local/bin/test_soap
Code:
/usr/bin/php /var/www/datalogger/test_soap.php