- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Watch for process and email if not present -
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
04-06-2006 12:20 AM
04-06-2006 12:20 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2006 12:24 AM
04-06-2006 12:24 AM
SolutionHere's a general purpose one. You can create a 'cron' task for it. Assume that you want to look for a process called "myproc" and mail/page if it isn't running:
# [ -z "`UNIX95= ps -C myproc -o pid= -o comm=`" ] && mailx -s "myproc" is not running!" root < /dev/null
Change the 'myproc' to match the basename of the process that you're interested in monitoring. As shown, this generates a mail to 'root'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2006 12:26 AM
04-06-2006 12:26 AM
Re: Watch for process and email if not present -
if [ `wc -l /tmp/proc.out | awk '{ print $1 }'` -gt 2 ]
then
echo "The process isn't running!" >> /tmp/mail.out
mail me@myserver < /tmp/mail.out
Something like that should do it.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2006 12:35 AM
04-06-2006 12:35 AM
Re: Watch for process and email if not present -
possible correction to Petes answer:
(No points please)
ps -ef | grep ${PROCNAME} | grep -v grep > /tmp/proc.out
if [ `wc -l /tmp/proc.out | awk '{ print $1 }'` -lt 1 ]
then
echo "The process isn't running!" >> /tmp/mail.out
mail me@myserver < /tmp/mail.out
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2006 12:42 AM
04-06-2006 12:42 AM
Re: Watch for process and email if not present -
You deserver more than 5 points for that - I lost my grep somewhere!!
Actually, we use an alias for "ps -ef |grep" that we call "psg", and I messed up the translation. Thanks for catching that.
Pete
Pete