How to check if a process is running or not in Linux, and execute something based on that?


#!/bin/sh

# Check if your application is running. Based on the application status, you can do whatever you want i.e. apply any logic.

# Mention SERVICE/DEPLOYABLE name.
SERVICE=’tomcat’

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo "$SERVICE service running"
# if logic
else
echo "$SERVICE is not running"
# else logic
fi

About these ads

About this entry