On Monday 28 April 2008, Joris Dobbelsteen wrote:
> Dear,
>
> I'm looking for a script that can kill an application after it has
> been running for a 'long' time. I like to measure the start time (as
> it offloads work, the CPU time time is not a good estimate). Does
> anyone have something useful or some pointers to something I can use
> for this?
>
> Preferably the script should monitor the processes that are currently
> running.

Assuming by "long time" you mean wall clock time, I would try this 
approach:

1. start your app from a wrapper script that starts your app then 
creates a file named like /var/run/my-monitor/<pid> and contains the 
output from 'date' when it was started. 
2. write another script that will read all files in /var/run/my-monitor/ 
and calculate the difference between start time and current time. If it 
passes some threshold, kill the process with the PID of the filename
3. run this second script from cron every minute:
   * * * * * root my-monitor-killer

alan


-- 
Alan McKinnon
alan dot mckinnon at gmail dot com

-- 
gentoo-user@lists.gentoo.org mailing list

Reply via email to