Here’s how you can check the uptime of a process using shell script:
# Application’s PID
app_pid=`ps ax | grep [app-pattern]| grep -v grep | awk ‘{print $1}’`
echo $app_pid# Application’s Uptime
app_uptime=`ps -p $app_pid -o “%t” | tail -1`
echo $app_uptime
Eg. If you like to know the uptime of an Apache ActiveMQ instance,
# Get ActiveMQ PID
activemq_pid=`ps ax | grep apache-activemq | grep -v grep | awk ‘{print $1}’`
echo $activemq_pid# Get ActiveMQ Uptime
activemq_uptime=`ps -p $activemq_pid -o “%t” | tail -1`
echo $activemq_uptime