Operating System - HP-UX
1825793 Members
2296 Online
109687 Solutions
New Discussion

How to get Start Date/Time of a Process in HP-UX

 
SOLVED
Go to solution
Alzhy
Honored Contributor

How to get Start Date/Time of a Process in HP-UX

Is there a command in HP-UX that can precisely show a process' start date and time?

Thanks.
Hakuna Matata.
14 REPLIES 14
Nicolas Dumeige
Esteemed Contributor

Re: How to get Start Date/Time of a Process in HP-UX

Hello

ps has the option your looking for.

Cheers

Nicolas
All different, all Unix
Peter Leddy_1
Esteemed Contributor

Re: How to get Start Date/Time of a Process in HP-UX

Hi,

Using the lstart specifier of ps shows the start date and time of a process. man ps for more info.

Peter
Kevin Wright
Honored Contributor

Re: How to get Start Date/Time of a Process in HP-UX

ps
RAC_1
Honored Contributor

Re: How to get Start Date/Time of a Process in HP-UX

ps -l (long listing will show start time/date)

Once the time lapsed is more then 24 hrs. only start date will be shown. Only time is shown if process is less than 24 hrs. old.

man ps gives more details.

Also you can use UNIX94 variable to get required info.

UNIX95= ps -l -o "stime,args"

Anil
There is no substitute to HARDWORK
John Payne_2
Honored Contributor

Re: How to get Start Date/Time of a Process in HP-UX

More precisely,

'ps -ef |grep {processname}'

eg. '

# ps -ef|grep inetd
root 21490 1 0 08:28:16 ? 0:00 /usr/sbin/inetd

or 'ps -ef|grep {pid}' if you know the pid.

eg.

# ps -ef|grep 21490
root 21490 1 0 08:28:16 ? 0:00 /usr/sbin/inetd

Hope it helps

John

Spoon!!!!
Alzhy
Honored Contributor

Re: How to get Start Date/Time of a Process in HP-UX



Thank you so far for the replies.. what I am after is some fort if a tool, ie. procinfo which will show Process start DATE and TIME or EPOCH Time is possible.

ie.
Fri Apr 16 07:59:56 PDT 2004
or
1082127596 (in Epoch Time - )

Hakuna Matata.
Alzhy
Honored Contributor

Re: How to get Start Date/Time of a Process in HP-UX

Actually similar to "glance -s" PROC_STARTTIME but I cannot seem to get a command line adviser syntax to give me a result of something like:

root# procinfo.ksh SomeLongRunningApp
PROC STARTTIME: Fri Apr 16 07:59:56 PDT 2004

Hakuna Matata.
Peter Leddy_1
Esteemed Contributor

Re: How to get Start Date/Time of a Process in HP-UX

Hi Nelson,

In my previuos post using the lstart of ps gives the output you are looking for and it does not matter if the process is running for more than 24 hours. You could use this in a script so you can specify what process you want info on.

IDEV:/usr/users/pleddy/scripts>ps -efo cmd,lstart | grep sysl
/usr/sbin/syslog Tue Apr 13 11:16:45 2004
grep sysl Fri Apr 16 16:06:59 2004

Alzhy
Honored Contributor

Re: How to get Start Date/Time of a Process in HP-UX

Hey Pedro,

ps -efo cmd,lstart | grep sysl

does not work,

even UNIX95=1 ps -efo cmd,lstart | grep sysl

does not work. and man page for ps on HP-UX 11.11 makes no mention of "lstart" as one of the "column formats" on ps..

What UNIX are you on?
Hakuna Matata.
Peter Leddy_1
Esteemed Contributor

Re: How to get Start Date/Time of a Process in HP-UX

Hi Nelson,

I did that on one of our Tru64 boxes and it works fine. Got a bit mixed up there, apologies.

Peter
Alzhy
Honored Contributor

Re: How to get Start Date/Time of a Process in HP-UX

I guess I would just have to reckon this from:

UNIX95=1 ps -efo etime,comm

Thanks for all your replies.....
Hakuna Matata.
Bruno Ganino
Honored Contributor

Re: How to get Start Date/Time of a Process in HP-UX

Hi Nelson, in my old system, if i remember righ, show with command "ps -edalf".
HTH
Bruno
Torino (Turin) +2H
Navin Bhat_2
Trusted Contributor
Solution

Re: How to get Start Date/Time of a Process in HP-UX

You could write a simple c program and use the pstat call and the pst_status structure to get the start time in epoch.

You can refer to the man page on pstat for more info....

struct __pst_status {
_T_LONG_T pst_idx;/* Index for further pstat() requests */
_T_LONG_T pst_uid; /* Real UID */
_T_LONG_T pst_pid; /* Process ID */
_T_LONG_T pst_ppid; /* Parent process ID */
_T_LONG_T pst_dsize; /* # real pages used for data */
_T_LONG_T pst_tsize; /* # real pages used for text */
_T_LONG_T pst_ssize; /* # real pages used for stack */
_T_LONG_T pst_nice; /* Nice value */
struct __psdev /* TTY of this process; -1/-1 if there isn't one */
pst_term;
_T_LONG_T pst_pgrp; /* Process group of this process */
_T_LONG_T pst_pri; /* priority of process */
_T_LONG_T pst_addr; /* address of process (in memory) */
_T_LONG_T pst_cpu; /* processor utilization for scheduling */
_T_LONG_T pst_utime; /* user time spent executing (in seconds) */
_T_LONG_T pst_stime; /* system time spent executing (in seconds) */
_T_LONG_T pst_start; /* time process started (seconds since epoch) */
.........
Alzhy
Honored Contributor

Re: How to get Start Date/Time of a Process in HP-UX

Thanks Navin.. bulls eye!

I've no done any C in the last 10 years.. would you mine posting a code that I could compile?

Also, would this structure (or something similar) be accessible in PERL?
Hakuna Matata.