LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 04-22-2013, 01:49 AM   #1
AshwiniIngale
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Rep: Reputation: Disabled
alternative for stat in Sun OS


Hi Guys,

I have been searching for alternative of stat command in Sun os. Can anybody help me to know how can I get process start time (I want it for older processes which are running for more than 15 days, hence ps and related options arent giving me expected result) or any option to find modification time since last epoch.
As I am not much familier with perl scrpting I would really appreciate if any body can help me to get this.
 
Old 04-22-2013, 02:02 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
what about /proc/$$/stat, and look for starttime http://man7.org/linux/man-pages/man5/proc.5.html ?
 
Old 04-22-2013, 02:44 AM   #3
AshwiniIngale
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
yes, I am going to use /proc/$PID but I need to get the stat of that process. SInce I am on Sun Os I directly cant execute stat ("/proc/$pid"). only /proc/$PID wont give me exact process start time. Any other way to get start time of process will aslo work..
 
Old 04-22-2013, 03:06 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
This should work:

Code:
# truss -t lstat64 -v lstat64 ls /proc/$pid/as 2>&1 | grep -w ct
 
1 members found this post helpful.
Old 04-22-2013, 03:58 AM   #5
AshwiniIngale
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
Thanks in tons!! Indeed its giving me output but I am not able to illustrate it. Could you please explain it in bit details for me.
If this is what giving me the process start time, you really made my life far better...
 
Old 04-22-2013, 04:07 AM   #6
AshwiniIngale
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
truss -t lstat64 -v lstat64 ls /proc/16973/as2>&1 | grep -w ct -->> This gives me Ambiguous output redirect error. but

truss -t lstat64 -v lstat64 ls /proc/16973 --> Is giving me below output. Could you please explain time stamp meaning in it.

d=0x05400000 i=3908 m=0040511 l=5 u=42715 g=40330 sz=832
at = Apr 14 11:58:27 BST 2013 [ 1365937107 ]
mt = Apr 14 11:58:27 BST 2013 [ 1365937107 ]
ct = Apr 14 11:58:27 BST 2013 [ 1365937107 ]

does mt and ct means mtime and ctime?
 
Old 04-22-2013, 09:50 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by AshwiniIngale View Post
truss -t lstat64 -v lstat64 ls /proc/16973/as2>&1 | grep -w ct -->> This gives me Ambiguous output redirect error.
You are missing a space between "as" and "2".
Quote:
does mt and ct means mtime and ctime?
These lines are indeed the timestamps the stat command would report (access, modification and change times).
 
1 members found this post helpful.
Old 04-23-2013, 12:21 AM   #8
AshwiniIngale
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
Superbb!! Thank you sooo much.. You really made my day far better... Thats again...
 
Old 04-24-2013, 04:56 AM   #9
AshwiniIngale
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
Hi,

Some how I am not able to grep the output of this turss... I have tried to get it in all way but some how I am not able to do it.. Can you please let me know how can I get only ct value stored in variable? I have tried using awk, sed but still not able to cut and store this value.. Can you help in this as well??
 
Old 04-24-2013, 05:00 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
as far as I remember truss writes its output to stderr, so you need to redirect it to stdout:
truss .... 2>&1 | grep ... or awk ...
probably you only missed a space before 2
 
Old 04-24-2013, 05:08 AM   #11
AshwiniIngale
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
Thanks Pan.. But I m not missing any space... PFB..
truss -t lstat64 -v lstat64 ls /proc/23238/as 2>&1 | grep -w ct
Ambiguous output redirect

Even I tired the below
truss -t lstat64 -v lstat64 ls /proc/23238 | awk '/ct/ {print $9}' and few more things to cut the field..

and everytime I end up on

lstat64("/proc/23238", 0xFFBFFAF0) = 0
d=0x07E80000 i=37316 m=0040511 l=5 u=5705 g=5705 sz=832
at = Apr 22 04:37:11 BST 2013 [ 1366601831 ]
mt = Apr 22 04:37:11 BST 2013 [ 1366601831 ]
ct = Apr 22 04:37:11 BST 2013 [ 1366601831 ]
bsz=512 blks=2 fs=proc
 
Old 04-24-2013, 06:22 AM   #12
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Use a standard shell (ksh, bash), csh is useless for scripting.
 
Old 04-24-2013, 09:50 PM   #13
AshwiniIngale
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
M arleady running it in bash..

#!/bin/bash
 
Old 04-25-2013, 12:46 AM   #14
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
You are not. The error message you posted (Ambiguous output redirect) is csh specific:
Code:
$ bash
$ truss -t lstat64 -v lstat64 ls /proc/$$/as 2>&1 | grep -w ct
        ct = Apr 25 07:41:34 CEST 2013  [ 1366868494.106588763 ]
$ csh
% truss -t lstat64 -v lstat64 ls /proc/$$/as 2>&1 | grep -w ct
Ambiguous output redirect
 
1 members found this post helpful.
Old 04-25-2013, 12:56 AM   #15
AshwiniIngale
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
ohh.. yes.. Got it.. I have looped several servers and ssh'ing those and executing truss on every one of them. Let me try how I can go to bash shell after ssh and then excute truss..
A big big thanks again!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] hidden symbol `stat' in /usr/lib/libc_nonshared.a(stat.oS) is referenced by DSO harig Programming 1 03-28-2013 06:34 AM
I can't install sun-java6-jdk sun-java6-bin sun-java6-jre citye Linux - Newbie 2 10-18-2009 04:54 AM
[SOLVED] gcc linker error - hidden symbol `stat' in /usr/lib/libc_nonshared.a(stat.oS) chaosless Linux - Software 1 09-17-2009 12:33 PM
[SOLVED] Sun suckage, any other Java alternative? cFoo Linux - Newbie 1 07-25-2009 04:34 AM
Linux stat to Windows Stat sridurai Programming 3 09-24-2004 04:07 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 06:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration