notify if a process take more than X time

2014-01-27 Thread Pol Hallen

Hi all,

I need add to my script a notify if a process take more than X time, so 
using ps I can see what time take a process:


ps -ao cmd,etime|grep backup
/bin/sh ./backup03:44:55

what's the easy way to do a notify by email?

redirect output of ps to file and use sed for analize the past time, 
next verify with if/then or there's a better way?


any idea?

thanks for help!

Pol


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/52e69ab8.8080...@fuckaround.org



Re: notify if a process take more than X time

2014-01-27 Thread Lars Noodén
On 27.01.2014 19:43, Pol Hallen wrote:
 Hi all,
 
 I need add to my script a notify if a process take more than X time, so
 using ps I can see what time take a process:
[snip]

Maybe use timeout(1) to send a signal (e.g. USR1) and have your script
trap that signal and send a mail when it receives it?

Regards,
/Lars


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/52e69f51.4040...@gmail.com



Re: notify if a process take more than X time

2014-01-27 Thread Karl E. Jorgensen
Hi

On Mon, Jan 27, 2014 at 06:43:20PM +0100, Pol Hallen wrote:
 Hi all,
 
 I need add to my script a notify if a process take more than X time,
 so using ps I can see what time take a process:
 
 ps -ao cmd,etime|grep backup
 /bin/sh ./backup03:44:55
 
 what's the easy way to do a notify by email?
 
 redirect output of ps to file and use sed for analize the past time,
 next verify with if/then or there's a better way?
 
 any idea?

Hm.. I don't know how to do the notify bit, but you *can* send a
signal to the offending process if it takes more than a certain time -
the command you need for this is timeout (part of GNU coreutils).
This is handy for killing off processes that get stuck...

Hope this helps
-- 
Karl E. Jorgensen


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20140127183000.GA27891@hawking



Re: notify if a process take more than X time

2014-01-27 Thread Pol Hallen

Hello Lars and thanks for your reply


Maybe use timeout(1) to send a signal (e.g. USR1) and have your script
trap that signal and send a mail when it receives it?


something like it, yep

if a process take long time, I need have a notification by email without 
change executing of that process.


Pol


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/52e6d984.30...@fuckaround.org



Re: notify if a process take more than X time

2014-01-27 Thread Robin
On 27 January 2014 17:43, Pol Hallen de...@fuckaround.org wrote:
 Hi all,

 I need add to my script a notify if a process take more than X time, so
 using ps I can see what time take a process:

 ps -ao cmd,etime|grep backup
 /bin/sh ./backup03:44:55

 what's the easy way to do a notify by email?

 redirect output of ps to file and use sed for analize the past time, next
 verify with if/then or there's a better way?

 any idea?

 thanks for help!

 Pol



Might be overkill but take a look at ps-watcher package if it is
available in your Debian version.
-- 
rob


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CAOZWb-r+dTVUmfCvLsgX4-duSA7P=dk+-zqwh9+unk9z6ag...@mail.gmail.com