LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Emails myself when a process dies (https://www.linuxquestions.org/questions/linux-newbie-8/emails-myself-when-a-process-dies-746575/)

prudens 08-10-2009 06:38 PM

Emails myself when a process dies
 
Hallo,

First I just wanna say that LQ is THE BEST Linux forums on the whole WWW... If I had unlimited money, I would donate no question at all!

OKej, now my question. How do I mail myself if a certain process dies on my server? My mail server is with Google Apps.

Thanks!

choogendyk 08-10-2009 07:45 PM

Not enough detail. Process on which server? What is it running? What's it's OS? And then your email ISP is Google Apps?

Without enough detail to really know, I might suggest a cron job that runs every few minutes and checks to see if that process is running. If it is not, use a command line email such as mailx to send a mail to your address. Of course, your server needs to be configured so that it can do that.

i92guboj 08-10-2009 07:52 PM

The absolute easiest way would be to launch the process wrapped into a shell script, like this one:

Code:

#!/bin/sh
<whatever_command> || <command to send mail>

This will send you an email each time a process dies with a non-zero status (which means it terminated with an error of some kind). I guess that's what you mean with "when a process dies". It won't send an email when the process ends without error or when it's killed by either you or init 6 (when halting your machine). But it all comes down to what do you mean by "die".

prudens 08-10-2009 08:09 PM

Say I have a process called PROCESS1 with a PID of 99999.

When It dies a email is sent to me. I use Google Apps.

Also, I use webmin... any easy ways?

centosboy 08-11-2009 03:02 AM

Quote:

Originally Posted by prudens (Post 3638580)
Say I have a process called PROCESS1 with a PID of 99999.

When It dies a email is sent to me. I use Google Apps.

Also, I use webmin... any easy ways?


easy way is what i92guboj quoted above or some sort of shell or perl script that checks every so minutes and if it doesnt find a process that matches a name - then sends an alert.

best way is set up some sort of monitoring system.

nagios, zabbix, open nms, there is a big choice.


All times are GMT -5. The time now is 03:18 AM.