I have an appliication that needs to be constantly running. At the moment I start the application by running it from the command line and occassionaly it will, for some reason, stop running and I have to start it again. I have written a script that checks if the application is running and if not start it back up. This works fine if manually run from the command line but ideally needs to be put in cron. When I put it in cron and run the .sh every 1 monute it runs fine (I check the output from cron and see it detects whether the application is running or not) however when it detects the application is not running it does not start it back up again (at least I don't see it when I issue ps-ef). Script output below:
ps -ef | grep -v grep | grep myapp
# if not found - equals to 1, start it
if [ $? -eq 1 ]
echo .eq 0 - myapp found - do nothing.
* * * * * /usr/src/chkapp.sh