Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ps -ef and awk

Status
Not open for further replies.

irishvber

Programmer
Sep 3, 2002
8
0
0
US
I am trying to retrieve the time a which a certain process is starting. SO I do

ps -ef | grep nameofprocess | awk field I need

The field I need is $5 the time field. However for processes running more than 24 hours it just gives me the date in "Jun 21" format otherwise it gives me the exact time eg "09:14:47". Is there anyway you can get the exact time for process older than 24 hours?

Secondly as the formats are differect for time date (and as the there is a space between month and day ) it is proving difficult.

Can anyone shed light to how I could
(1) Find full time date
and/or
(2) how I would manage to determine whether or not process is more than 24 hours?
 
- efotime whats that

I resolved this by:

DBST=`ps -ef|grep DBPROCESS|grep $OSID|awk '{print $5}'|cut -c1`

if [ `echo $DBST|grep ^[0-9]` ]; then
ps -ef|grep $DBPROCESS|grep $OSID|awk '{print $5}'
else
ps -ef|grep $DBPROCESS|grep $OSID|awk '{print $5 $6}'
fi

}
 
ps -ef|grep whatever|awk '{print $1}'

$1 = column 1
$2 = column 2
Etc.



-
| Mike Nixon
| Unix Admin
-------------
 
irishvber:
see man pages, in particular the -o option of ps
since s5r4 (1995 !!) you can tell ps to show you
what you desire in the preferred manner.

let ps do the job:
you want exec-name+args and pid
ps -efoargs,pid
you want pid, ppid and exec-name+args
ps -efopid,ppid,args

:) guggach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top