Sunday, 15 September 2013

Identify PID of long running process

Identify PID of long running process

I am not a very good programmer, please help me with this.
I need to identify long running process and save pid of that process to a
file. With the below command I am able to identify age of long running
process. But after this I am struck with how to grep PID of that long
running process? Any help is greatly appreciated.
ps -eo pid,etime,cmd | grep DSD.RUN | awk '{print $2}' | ./script.sh |
xargs -I [] bash -c 'if [ "[]" -gt "86400" ]; then echo []; fi'
Script.sh: (got this from stackoverflow post)
#!/bin/bash
awk -F $':' -f <(cat - <<-'EOF'
{
if (NF == 2) {
print $1*60 + $2
} else if (NF == 3) {
split($1, a, "-");
if (a[2] > 0) {
print ((a[1]*24+a[2])*60 + $2) * 60 + $3;
} else {
print ($1*60 + $2) * 60 + $3;
}
}
}
EOF
) < /dev/stdin

No comments:

Post a Comment