Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] Script to kill long-running application "Anton S. Ustyuzhanin" <kit@×××××××××.kz>
Re: [gentoo-user] Script to kill long-running application Joris Dobbelsteen <joris@××××××××××××××××××.nl>