Cron job to restart Tomcat when it crashes

My Lucee server is crashing because I haven’t quite figured out how to
configure it properly. As a temporary solution I have written a bash script
to run as a cron job every 5 minutes. This should check if TC is running
and accessible and restart Lucee/TC if not. I would appreciate constructive
comments or improvements. I have the website running on port 80 on Tomcat
(no Apache). This is running as a system cron.

#!/bin/bash
if sudo netstat -tulpen | grep ":80 " > /dev/null 2>&1 && ps -ef | grep
tomcat | grep java > /dev/null 2>&1
then
echo “Tomcat Running” > /dev/null
else
echo “Tomcat Stopped” > /dev/null
sudo /opt/lucee/lucee_ctl restart
fi

Installing Fusion Reactor (http://www.fusion-reactor.com/ ) on this server would help you a great deal and it can handle the restarts after crashes. It will also give you a ton of useful information that will help you in tuning your server, along with identifying bottlenecks in your application.On December 17, 2015 at 11:29:22 PM, Michael Wood (@Michael_Wood) wrote:

My Lucee server is crashing because I haven’t quite figured out how to configure it properly. As a temporary solution I have written a bash script to run as a cron job every 5 minutes. This should check if TC is running and accessible and restart Lucee/TC if not. I would appreciate constructive comments or improvements. I have the website running on port 80 on Tomcat (no Apache). This is running as a system cron.

#!/bin/bash
if sudo netstat -tulpen | grep ":80 " > /dev/null 2>&1 && ps -ef | grep tomcat | grep java > /dev/null 2>&1
then
echo “Tomcat Running” > /dev/null
else
echo “Tomcat Stopped” > /dev/null
sudo /opt/lucee/lucee_ctl restart
fi

Love Lucee? Become a supporter and be part of the Lucee project today! - http://lucee.org/supporters/become-a-supporter.html

You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/d149870b-6bf7-46f7-a9a9-c0d6b079faff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.