lkml.org 
[lkml]   [2004]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectchecking if a job still uses the CPU
I want to check a job periodically whether it still uses the CPU. If
not, I want to kill it. The latest solution I found is at

http://madduck.net/~madduck/scratch/worker.sh
http://madduck.net/~madduck/scratch/job.sh

worker.sh starts job.sh and polls /proc/$PID/stat:16 (the 16th
field: cutime) regularly. As soon as it stopped changing, the job is
killed.

This works fine as long as job.sh does not start jobs itself which
run longer than the period used to check in the worker (7 seconds in
my example). If job.sh's children take longer than 7 seconds to
complete, job.sh might get killed because the cutime value of
a process in /proc is only updated whenever a child returns.

Is there another way to achieve what I am trying to do? How can
I kill jobs that are idling and have not used the CPU in $DELAY
time?

Thanks,

--
martin; (greetings from the heart of the sun.)
\____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck

invalid/expired pgp subkeys? use subkeys.pgp.net as keyserver!
spamtraps: madduck.bogus@madduck.net

"we are like shop windows in which we are continually arranging,
concealing or illuminating the supposed qualities other ascribe to us
-- in order to deceive ourselves."
- friedrich nietzsche
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.039 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site