How To Find Out How Long A Process Has Been Running In Linux

Find Out How Long A Process Has Been Running In Linux

2 Responses

  1. jhuebel says:

    This bash script will return the elapsed time (in seconds) of any processes with the specified name, without any “ELAPSED” text or whitespace. If there are multiple processes, then the times for each process are seperated by newlines.

    Paste this into a file called piduptime.sh and make it executable. Syntax is “piduptime.sh &ltprocess name&gt”.

    #!/bin/bash

    PIDS=”$(pidof $1)”
    for PID in $PIDS
    do
    ps -o etimes -p $PID | sed -n 2p | sed ‘s/ //g’
    done

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.