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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 26 other followers

%d bloggers like this: