Logging with Start stop daemon
Hey,
I wrote a script to start an algorithm on one of my database machines. After some tweaking I have gotten the Start, stop, restart, and reload to function fine. My problem is that with the start stop daemon, the logging of stdout and stderr logs that of SSD, not what I am executing. Is there a way to log the execute commands output? Below is the script to save time in anyone needing to ask. Thanks.
#!/bin/sh
#Script to start and stop algorithm control
NAME=algorithm_control
PIDFILE=/var/run/$NAME.pid
export JAVA_HOME=/usr/share/java/j2sdk1.4.2_05/bin
export CLASS_PATH=/usr/local/digonex/lib
export POSTGRESQL_PATH=/usr/share/java
SSD=`which start-stop-daemon`
export login_name=******
export login_password=******
mapserver_IP="digsecdb"
START="$JAVA_HOME/java"
PARAMETERS="-cp $POSTGRESQL_PATH/postgresql.jar:$CLASS_PATH/AlgorithmControl.jar:$CLASS_PATH/DTISoapClient.jar AlgorithmControl.AlgorithmControl $login_name $login_password $mapserver_IP >> /var/log/algorithm_control.log 2>&1"
case "$1" in
'start')
echo "Starting up the $NAME"
#`$START` >> /var/log/algorithm_control.log 2>&1 &
$SSD --start --make-pidfile --pidfile $PIDFILE --background --exec $START -- $PARAMETERS
;;
'stop')
echo "Stopping the $NAME"
kill -s INT `cat $PIDFILE`
;;
'restart')
echo -n "Restarting $NAME"
kill -s INT `cat $PIDFILE`
sleep 3
i=go
while [ "$i" = go ]
do
ps aux | grep -v restart | grep [a]lgorithm > /root/algorithm_tmp.log
if [ -s /root/algorithm_tmp.log ]; then
sleep 5
else
$SSD --start --make-pidfile --pidfile $PIDFILE --background --exec $START -- $PARAMETERS
i=""
fi
rm /root/algorithm_tmp.log
done
;;
'reload')
echo -n "Reloading Algorithm"
kill -s HUP `cat $PIDFILE`
;;
*)
echo "Usage: /etc/init.d/algorithm {start|stop|restart}"
exit 1
;;
esac
exit 0
Any help on getting this to log the executed command would help me immensly. Thanks a lot.
|