FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 04-28-2008, 08:12 AM
Joris Dobbelsteen
 
Default Script to kill long-running application

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.


Thanks,

- Joris
--
gentoo-user@lists.gentoo.org mailing list
 
Old 04-28-2008, 08:59 AM
Alan McKinnon
 
Default Script to kill long-running application

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
 
Old 04-28-2008, 09:04 AM
"Anton S. Ustyuzhanin"
 
Default Script to kill long-running application

Alan McKinnon wrote:

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


Also take a look at /etc/security/limits.conf (pam_limit)
--
gentoo-user@lists.gentoo.org mailing list
 
Old 04-28-2008, 11:24 AM
Joris Dobbelsteen
 
Default Script to kill long-running application

Alan McKinnon wrote:

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


Thanks for your support, however I'm looking for more of less something
already created (sames.


However afer a complete day searching (total time) I refound what I had
spotted a couple weeks earlier:

<http://sial.org/code/perl/scripts/timeout.pl>
It doesn't pass back exit codes, which is a major problem for me, as I
rely on them (in the upper level script)...


Regarding pam_limits: I'm a user on the box, not the admin... So this
won't work.


- Joris

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

Thread Tools




All times are GMT. The time now is 08:28 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org