Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Linux Process Start Time

by pileofrogs (Priest)
on Jul 27, 2009 at 17:43 UTC ( [id://783616]=note: print w/replies, xml ) Need Help??


in reply to Re: Linux Process Start Time
in thread Linux Process Start Time

I've had the output of ps change on me in a distro version update. But, actually, you're probably right, I wasn't using a POSIX or BSD output format. That would stabilize it.

And yes, /proc isn't portable. It might be a little bit portable. I know it's optional on OpenBSD, for instance.

Looking for the same process name twice won't help. I want to know the age. I think I'll add an example to the OP.

Good point about POSIX or BSD ps output.

--Pileofrogs

Replies are listed 'Best First'.
Re^3: Linux Process Start Time
by Illuminatus (Curate) on Jul 27, 2009 at 18:22 UTC
    Sorry, I should have been clearer. Let's say you run the monitor in cron every 10 minutes:
    • try to open /tmp/monitor_info
    • if non-existent, generate pid/procname list, write to /tmp/monitor_info and exit
    • read file data into array/hash
    • generate pid/procname list using aforementioned ps command
    • compare lists. If same pair shows up in both, kill it (it's been running longer than 10 minutes).
    • write new list to /tmp/monitor_info
    Adjust cron interval to be a time comfortable to ensuring that process is broken. It is a little more complicated if you have processes that have different 'comfort intervals', but you could simply include a count to each line in /tmp/monitor_info to manage this.

    This script is short and easy. Does that make sense?

    fnord

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://783616]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-23 22:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found