Hi All,
Just wanted to let you know that I have found a solution to my
problem, though I can't entirely explain it yet. As mentioned
earlier, this script was designed to run as a daemon, i.e. run in the
background. This is what I was doing to daemonize the script:
Daemon()
{
while :
do
checkStatus
sleep 1
done
}
trap CleanupExit INT
trap CleanupExit TERM
trap CleanupExit ILL
trap CleanupExit QUIT
trap CleanupExit ABRT
trap CleanupExit KILL
if [ x"$1" = x"start" ]; then
Daemon 0<&- 1>/dev/null 2>&1 &
echo $! > $PIDFILE
elif [ x"$1" = x"stop" ]; then
TMP=`cat $PIDFILE`
kill $TMP
CleanupExit
else
:
fi
When running like this, I was seeing 'touch' command failures inside
function fsaccesstest() shown previously.
I did an experiment last night and ran this script in the foreground
(removed the &) from the call to Daemon. To my surprise, I did not
see any errors with the 'touch' command.
I then went back and changed how I was turning this script into a
daemon, by using the start-stop-daemon utility instead like this:
start-stop-daemon --start --background --quiet --exec $DAEMON
Once I did this, my shell script is now running in the background
without any errors. Life is good.
Perhaps when I was calling Daemon & as shown above, the parent process
was not exiting properly and was somehow interfering in the child
process execution. I'm not really sure.
Anyhow, I'm past this problem now. Thank you all for the good ideas
and generous help.