How to obtain the creation time of a process

  • Follow


I started to work on HP-UX ia64 11.23. And this is a completely new platform
for me.

I wonder if there's any way to get the time when a process is created, given
only its pid. This is possible on Solaris or AIX by extracting information
from /proc. There's no procfs on HP-UX, however. I tried to use 'ps', but it
does not support -o option and I don't know how to make it output 'etime'.

I prefer to solve this problem in C code. But it is also OK to use shell
programming. Can someone give me a hand?

Many thanks in advance.

Zhongchao


0
Reply Zhongchao 10/22/2004 2:32:05 PM

Zhongchao Yu wrote:

> 
> I wonder if there's any way to get the time when a process is created,
> given only its pid. This is possible on Solaris or AIX by extracting
> information from /proc. There's no procfs on HP-UX, however. I tried to
> use 'ps', but it does not support -o option and I don't know how to make
> it output 'etime'.
> 

# export UNIX95=1
# date
Fri Oct 22 10:45:28 EDT 2004
# vi /tmp/foo &
[1]     10701
# ps -o stime -p 10701
   STIME
10:45:32
[1] + Stopped(SIGTTOU)            vi /tmp/foo &

0
Reply Kirk 10/22/2004 2:46:52 PM


Thanks. But for processes older than 24 hours, stime only outputs the date
rather than time. Also as I said, -o was an illegal option on the platform I
am working on.

I guess I found a way by using pstat functions to get the information.

Zhongchao

"Kirk Gardner" <kg@example.com> wrote in message
news:w39ed.1419$h71.1298@news.cpqcorp.net...
> Zhongchao Yu wrote:
>
> >
> > I wonder if there's any way to get the time when a process is created,
> > given only its pid. This is possible on Solaris or AIX by extracting
> > information from /proc. There's no procfs on HP-UX, however. I tried to
> > use 'ps', but it does not support -o option and I don't know how to make
> > it output 'etime'.
> >
>
> # export UNIX95=1
> # date
> Fri Oct 22 10:45:28 EDT 2004
> # vi /tmp/foo &
> [1]     10701
> # ps -o stime -p 10701
>    STIME
> 10:45:32
> [1] + Stopped(SIGTTOU)            vi /tmp/foo &
>


0
Reply Zhongchao 10/22/2004 3:04:27 PM

On 22/10/2004 15:32, Zhongchao Yu wrote:
> I wonder if there's any way to get the time when a process is created, given
> only its pid. This is possible on Solaris or AIX by extracting information
> from /proc. There's no procfs on HP-UX, however. I tried to use 'ps', but it
> does not support -o option and I don't know how to make it output 'etime'.
> 
> I prefer to solve this problem in C code. But it is also OK to use shell
> programming. Can someone give me a hand?
> 

You can use the pst_start field in the pst_status structure returned by
pstat_getproc (This returns the time the process started as an integer - you can
manipulate with the normal C time functions).


Dave G

0
Reply David 10/22/2004 5:32:01 PM

3 Replies
240 Views

(page loaded in 0.37 seconds)

Similiar Articles:













7/28/2012 12:09:57 AM


Reply: