- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Shell Scripts for monitoring and starting the ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2007 08:26 AM
03-27-2007 08:26 AM
I want to monitor a process and whenever it stops we should receive email notification and execute the command
for starting the process.
For example: i want to monitor the process name "tulip-web-admin". Once it is found that
the process is not running then it should send email notification and start /opt/somedirectory/tulip.sh script.
And we should receive the email notification that process has been re-started.
Can any one suggest korn shell script for this ?
Thanks,
Shiv
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2007 08:37 AM
03-27-2007 08:37 AM
Solution#!/usr/bin/sh (or #!/usr/bin/ksh if you insist)
typeset PROCESS-"tulip-web-admin"
typeset -i STAT=0
UNIX95=1 ps -C "${PROCESS}" -o pid='' > /dev/null 2>&1
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
/opt/somedirectory/tulip.sh # you may ned a & to start in background ?
STAT=${?}
echo "Restarted" | mail mickey@mouse.com
fi
exit ${STAT}
You then cron this script to run every 5 minutes or so.
Generally this is a Mickey Mouse solution because it appears that you are trying to fix the symptoms rather than fixing the problem itself --- ie, why is the process dying?
- Tags:
- PS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2007 08:41 AM
03-27-2007 08:41 AM
Re: Shell Scripts for monitoring and starting the process
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2007 09:01 AM
03-27-2007 09:01 AM
Re: Shell Scripts for monitoring and starting the process
There are several ways to do what you want but continuously running ps could impose an abnormal load on the system.
-------------------------------------------
typeset PROCESS-"tulip-web-admin"
typeset -i STAT=0
typeset -i DELAY=10
while [[ 1 -eq 1 ]]
do
UNIX95=1 ps -C "${PROCESS}" -o pid='' > /dev/null 2>&1
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
/opt/somedirectory/tulip.sh # you may ned a & to start in background ?
STAT=${?}
echo "Restarted" | mail mickey@mouse.com
fi
sleep ${DELAY}
done
exit ${STAT}
---------------------------------------
This would check every ${DELAY} seconds.
Here's another approach leveraging wait (and is a bit cleaner):
typeset -i CHILD=0
while [[ 1 -eq 1 ]]
do
/opt/somedirectory/tulip.sh &
CHILD=${!}
wait ${CHILD}
echo "Restarted" | mail mickey@mouse.com
done
Either of these scripts should be put set up as an rc'ed command so that this is the sole means of starting the script. HOWEVER, you still seem to be fixing symptoms of a bad application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2007 09:02 AM
03-27-2007 09:02 AM
Re: Shell Scripts for monitoring and starting the process
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 04:47 AM
03-28-2007 04:47 AM
Re: Shell Scripts for monitoring and starting the process
I have been developing a new tool - sentinel - which does what you want (and more) and I am looking for beta testers for it.
Could you send me your contact so that I could give you instructions on how to use it? It comes bundled with WDB 5.6 and later available on the web, but is not an officially supported tool until we can understand its use needs.
Thanx!
Veeru@hp.com
- Tags:
- sentinel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 04:50 AM
03-28-2007 04:50 AM
Re: Shell Scripts for monitoring and starting the process
Please email me on:
sksonkar@gmail.com
Thanks,
Shiv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 05:54 AM
03-28-2007 05:54 AM
Re: Shell Scripts for monitoring and starting the process
Shame on you! You asked this very question last year. If you examine the very rich number of question and responses associated with YOUR profile:
https://forums1.itrc.hp.com/service/forums/publicProfile.do?userId=CA1283218&forumId=1
...then you would find:
https://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=996430
...from January 2006 which answered this question!!!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 07:33 AM
03-28-2007 07:33 AM
Re: Shell Scripts for monitoring and starting the process
Except I noticed it and told Veeru about it. :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 10:39 AM
03-28-2007 10:39 AM
Re: Shell Scripts for monitoring and starting the process
I changed my job and was not able to trace the earlier responses. Unfortunately, after posting the question i came to know how to look for the previous responses.
I apologize with the forum members.
Best Regards,
Shiv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 11:14 AM
03-28-2007 11:14 AM
Re: Shell Scripts for monitoring and starting the process
One of the things I use my forums profile is to find good threads from the past.
When I find a thread that is really good, I add it to my ITRC favorites. Two reasons:
1) So I can use the thread to handle a situation I don't often have to perform. Memory aid really.
2) So I can cut and paste code or a thread link for answering ITRC questions.
An example of number 2 is the mirror with mirror/ux post I often use. It comes from my forums favorite.
Don't worrry about the mistake, I make more than my share posting replies.
No need to point this post, just don't want you to feel so bad.
All is forgiven. By me, I don't speak for others.
The question did seem very familiar to me.
:-)
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 12:06 PM
03-28-2007 12:06 PM
Re: Shell Scripts for monitoring and starting the process
Remembering every detail, or even how to do something, is less important than learning *how* to find an answer.
Sometimes the "how" is searching manpages and *trying* to write something that fits your needs and solves a problem. Perfection is an endless journey.
The Chinese say, "Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime."
Take my gentle admonishment in my first response in the manner I intended it: an encouragement to fish.
You need not award points for this.
Regards to you, Shiv!
...JRF...