monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Monitor long running processes and kill them


From: Eric PAILLEAU
Subject: Re: Monitor long running processes and kill them
Date: Mon, 26 Mar 2012 18:45:00 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

Hello,

another hint :

You can use the 'timeout' command before the launch program (in the start/stop script in the init.d directory) with the limit of time :

(timeout   3600   /usr/bin/mydaemon ) &

this will kill the mydaemon process after 1 hour.
But the process must treat SIGTERM nicelly.

On some platform timeout have another argument   -k  ...  for using SIGKILL after another delay if SIGTERM does not
work.

Be carefull that timeout fork the command in its own process group, this may cause some trouble
in some case ...

Regards


Le 26/03/2012 14:27, Martin Pala a écrit :
Hi,

if the process does have a pidfile, it is usually updated only when the process starts - in such case you can use the timestamp test to restart the process, for example:
--8<--
check file myprocpid with path /var/run/myproc.pid
   if timestamp > 3 days then exec "/etc/init.d/myproc restart"
--8<--


We can easily implement uptime test to Monit in the future, so it can be possible to use somethig like:
--8<--
check process myproc with pidfile /var/run/myproc.pid
   start program = …
   stop program = ...
   if uptime > 3 days then restart
--8<--


Regards,
Martin


On Mar 16, 2012, at 10:46 PM, Christian Becker wrote:

Hi There,

is it possible with monit to check how long a process is running and kill them, if it exceeds the prefered time.

Kind regards
Chris
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


--

reply via email to

[Prev in Thread] Current Thread [Next in Thread]