get startup / running time of a process?

C

Crom

Is there a portable way of obtaining the start up and/or elapsed time
since start (which I suppose could be calculated given the start time,
so no biggy, just need the start time.)

I've been searching exhaustively in both google groups without many
leads. My target systems are Linux and Freebsd, though a portable
solution would be nice, but not necessary.

So far the only way I could find is parsing output from the ps command,
but it's a little different from system, and some show the time as Tue01
(to indicate something started @ 1 o'clock on tuesday, which is a dead
end in the sense of raw time value hunting, if you know what I mean; in
others words you can't derive ac actually date/time from a value like
that!

Any help in this would greatly be appreciated.
 
G

Gregory Toomey

Crom said:
Is there a portable way of obtaining the start up and/or elapsed time
since start (which I suppose could be calculated given the start time,
so no biggy, just need the start time.)

I've been searching exhaustively in both google groups without many
leads. My target systems are Linux and Freebsd, though a portable
solution would be nice, but not necessary.

So far the only way I could find is parsing output from the ps command,
but it's a little different from system, and some show the time as Tue01
(to indicate something started @ 1 o'clock on tuesday, which is a dead
end in the sense of raw time value hunting, if you know what I mean; in
others words you can't derive ac actually date/time from a value like
that!

Any help in this would greatly be appreciated.

In linux the /proc filesystem has lots of information.

gtoomey
 
S

Sherm Pendley

Crom said:
Is there a portable way of obtaining the start up and/or elapsed time
since start (which I suppose could be calculated given the start time,
so no biggy, just need the start time.)

I've been searching exhaustively in both google groups without many
leads. My target systems are Linux and Freebsd, though a portable
solution would be nice, but not necessary.

A minute of perldoc is worth an hour of Google. From 'perldoc perlvar':

$BASETIME
$^T The time at which the program began running, in seconds since
the epoch (beginning of 1970). The values returned by the -M,
-A, and -C filetests are based on this value.

sherm--
 
P

Peter Michael

Crom,

Crom said:
Is there a portable way of obtaining the start up and/or elapsed time
since start (which I suppose could be calculated given the start time,
so no biggy, just need the start time.)

have a look at $^T in the perlvar man page.

Peter
 
A

Alfred Z. Newmane

Sherm said:
A minute of perldoc is worth an hour of Google. From 'perldoc
perlvar':

$BASETIME
$^T The time at which the program began running, in seconds since
the epoch (beginning of 1970). The values returned by the
-M, -A, and -C filetests are based on this value.

Correct me if I'm wrong but isn't that only for the running script
itself? I got the impression the op wanted to do it for any given app
thats running on the system out side of the script.
 
C

Crom

Peter said:
Crom,



have a look at $^T in the perlvar man page.

Sorry I was not clearer, I wanted ot find this information for _other_
runing programs on the system.
 
B

Brian McCauley

Crom said:
Sorry I was not clearer, I wanted ot find this information for _other_
runing programs on the system.

Fundamentally I think the answer is no. The only way to make a portable
way would be to produce a module that includes a load of OS specific
ways and presents a single API. If such a module existed (and were
published) I'd expect it would be on CPAN and start with Proc::.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top