Created
June 15, 2012 14:33
-
-
Save rcalsaverini/2936760 to your computer and use it in GitHub Desktop.
Get running time of a process given a pid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pidlist=`ps ax | grep -i -E $1 | grep -v grep | awk '{print $1}' | grep -v PID | xargs echo` | |
for pid in $pidlist; do | |
sincetime $pid | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
init=`stat -t /proc/$1 | awk '{print $14}'` | |
curr=`date +%s` | |
seconds=`echo $curr - $init| bc` | |
name=`cat /proc/$1/cmdline` | |
echo $name $seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These are two simple scripts to check the age of running processes. The command:
should output the age of the process with pid= in seconds.
The command:
where is a string or regular expression, will output all processes matching the pattern and their ages in seconds.