Gentoo Archives: gentoo-user

From: "Anton S. Ustyuzhanin" <kit@×××××××××.kz>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Script to kill long-running application
Date: Mon, 28 Apr 2008 09:05:20
Message-Id: 4815932E.4040505@miras.edu.kz
In Reply to: Re: [gentoo-user] Script to kill long-running application by Alan McKinnon
1 Alan McKinnon wrote:
2 > On Monday 28 April 2008, Joris Dobbelsteen wrote:
3 >> Dear,
4 >>
5 >> I'm looking for a script that can kill an application after it has
6 >> been running for a 'long' time. I like to measure the start time (as
7 >> it offloads work, the CPU time time is not a good estimate). Does
8 >> anyone have something useful or some pointers to something I can use
9 >> for this?
10 >>
11 >> Preferably the script should monitor the processes that are currently
12 >> running.
13 >
14 > Assuming by "long time" you mean wall clock time, I would try this
15 > approach:
16 >
17 > 1. start your app from a wrapper script that starts your app then
18 > creates a file named like /var/run/my-monitor/<pid> and contains the
19 > output from 'date' when it was started.
20 > 2. write another script that will read all files in /var/run/my-monitor/
21 > and calculate the difference between start time and current time. If it
22 > passes some threshold, kill the process with the PID of the filename
23 > 3. run this second script from cron every minute:
24 > * * * * * root my-monitor-killer
25 >
26 > alan
27
28 Also take a look at /etc/security/limits.conf (pam_limit)
29 --
30 gentoo-user@l.g.o mailing list