Libervis Network - For a Free WorldLibervis.com :: Planet Libervis :: Nuxified.org :: MobiLiberty.com  |  IRC | Web hosting powered by www.shopcentar.hr

Need an uptime command -- no, not 'uptime'

 Submitted by supermike on Fri, 2006-06-02 01:41.  
supermike's picture
Writers Team
Posts: 471
Joined: 2006-02-17

I need an uptime command that I can run, and not the 'uptime' command. I'm not interested in this case in how long the OS has been up, but how long a PID (Process ID) has been running in memory. Anyone got an idea?

 

--

When in doubt, follow the penguins.



 Fri, 2006-06-02 02:27  I tried looking for such
libervisco's picture
Administrator
Posts: 3856
Joined: 2006-05-04

I tried looking for such info in top or htop (a nicer version of top) thinking that the "TIME" field may be the uptime, but it turns out it is only the CPU time.

Another idea is the procinfo command, but that displays only general uptimes of the system and some other processes info..

Now I'm not sure if PIDs even track uptime information for themselves. I suppose they should.

Well.. I hope that at least takes you closer to the right idea. I'll let you know if I find out more.

There has to be a way..



 Fri, 2006-06-02 10:30  just a lucky guess: I
tbuitenh's picture
Posts: 1059
Joined: 2005-12-21

just a lucky guess: I think

ls -l /proc | grep <pid>

will show you what time <pid> was created

--

CAN I HAS FIXD CAPSLOK KEE PLZ?



 Tue, 2006-06-06 22:30  tbuitenh wrote:just a
Posts: 84
Joined: 2006-01-02
tbuitenh wrote:

just a lucky guess: I think

ls -l /proc | grep

will show you what time was created

Hah, that's pretty creative. I like that Smiling

All ye need to do now is run that through a script to parse that timestamp into hours.



 Sun, 2006-06-18 10:29  just a few simple commands
free-zombie's picture
ModeratorWriters Team
Posts: 805
Joined: 2006-03-08

just a few simple commands Eye-wink

###
# function determines uptime of a specified process ($1).
# tested in zsh 4.3.2 and bash 3.1 (Debian GNU/Linux SID)
###
function pidup ()
{
(( secs = $( date +%s ) - $( date --date="$( ls -l /proc | awk "/$1/ { printf (\"%s %s\",\$6,\$7) ; }" )" +%s ) ))
echo up for $(( $secs / 3600 ))h $(( ($secs % 3600) / 60 ))m $(( $secs % 60 ))s
}


 Tue, 2007-09-11 14:36  yay. I would've wanted to
Posts: 84
Joined: 2006-01-02

yay. I would've wanted to try it but I guess you beat me to it. Smiling



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

We have 1706 members who wrote 2002 articles and 11690 comments. Welcome to our newest member, nabim1!

Who's online

There are currently 0 users and 12 guests online.
About | FAQ | Goodies | Link | Contact | IRC
Nuxified RSS feed
Welcome >  |  Need help? Register here and ask away! | Show what's new