RedTiger84
July 20th, 2007, 10:17 PM
Hello,
I wrote a small script to start a little tool. Since I want to start it at system startup and check whether the program is still running from time to time and restart it if necessary (kind of buggy little tool), I wrote the following:
#! /bin/bash
RES=`ps -A | grep toolname -c`
if [ $RES -lt 1 ]
then
/usr/sbin/toolname > /dev/null 2> /dev/null &
echo "tool started"
else
echo "tool already running"
fi
This script works perfectly fine when placed in my homedir. But it stops working when copied to /etc/init.d. When the script is copied there and is called, it always tells me that the tool is already running. When I print the results of a `ps -A` command in this script, it returns a list processes that is definitely not up to date. If I run `ps -A` from this directory from the normal shell, everything is fine.
Can anybody explain this behaviour?
I am using Ubuntu 7.04 with all available updates.
Thanks and regards,
Christoph
I wrote a small script to start a little tool. Since I want to start it at system startup and check whether the program is still running from time to time and restart it if necessary (kind of buggy little tool), I wrote the following:
#! /bin/bash
RES=`ps -A | grep toolname -c`
if [ $RES -lt 1 ]
then
/usr/sbin/toolname > /dev/null 2> /dev/null &
echo "tool started"
else
echo "tool already running"
fi
This script works perfectly fine when placed in my homedir. But it stops working when copied to /etc/init.d. When the script is copied there and is called, it always tells me that the tool is already running. When I print the results of a `ps -A` command in this script, it returns a list processes that is definitely not up to date. If I run `ps -A` from this directory from the normal shell, everything is fine.
Can anybody explain this behaviour?
I am using Ubuntu 7.04 with all available updates.
Thanks and regards,
Christoph