Shell Script to find a process using grep and taking an accortion accordingly using if else

x=start.sh
y=`ps -ef | grep start.sh | awk '{print $9}' |head -1`
if [ $y = $x ]
then
	mail -s "SUCCESS: Fetcher Hourly Check" utsav.sabharwal@nextag.com,jyadav@nextag.com -a ""<<< "Hie Team,

This is to inform you that start.sh is running smoothly. So just sit back and chill.. .

I would recheck after one hour.

Best Regards,
Unix Script
etc/cron.hourly/mycron.sh
BETA Fetcher"

else
	mail -s "FAILURE: Fetcher Hourly Check" utsav.sabharwal@nextag.com,jyadav@nextag.com -a ""<<< "Hie Team,

This is to inform you that start.sh is not running on BETA URLBroker. Take appropriate action asap.

Please note, that I have been designed to update you guys every hour if I don't find a paster process running on my machine.

Best Regards,
Unix Script
/mycron.sh
BETA Fetcher"

Advertisements

One thought on “Shell Script to find a process using grep and taking an accortion accordingly using if else

  1. Matteo Kranz says:

    Thanks so much for the post.Really thank you! Fantastic.

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

%d bloggers like this: