I am trying to create a monitoring script in Shell script. When a particular process/thread is not available, i have to kick a background process which will be never ending. This works fine when i manually run my monitoring script. However, this monitoring script has to be run every 10 minutes(i tried crontab for scheduling). Now, the problem is the background process which there in the monitoring script is not running if the script is called through the crontab.
Any help is appreciated! I am open to use any other Linux schedulers too if it available for free.
The monitoring script pseudo code as follows:
#!/bin/sh
backgroundProcessCount=`ps -ef | grep backgroundProcess | grep -v grep | wc -l`
echo $backgroundProcessCount
#### Start if not already running
if [ $backgroundProcessCount-eq 0 ]
then
echo Background Process is not running!!!
sh /usr/share/bin/backgroundProcess.sh
echo Background Process....
else
echo Background Process NOT Started!!!!
fi
Thanks!