Before I saw this questions and its answers, I made a little bash script. This is still useful, if you don't have root rights and acct isn't installed or you don't invoke your command directly (in my case: I use a gui to setup background processes). You need to get the PID before running (anyone interested in adding it into the script? :)
#!/bin/bash echo "Checking run time" read -p "What is the pid? " PID while true; do # sleep needed! used to reduce cpu usage and mass of output sleep 5 ps -eo uid,pid,etime | egrep '$PID' | egrep '$UID' done
With this, find the PID of PROCESS_NAME
ps aux | awk 'NR == 1 || /PROCESS_NAME/'
Actually I tried combining USER-ID and PID to make the script non-ambigious, but it's not that easy... ps -eo uid,pid,etime | egrep '$UID[[:space:]]$PID' don't seem to work always...