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...
apt.ubuntu.com
, and then the image got deleted from imgur. I must have used it hundreds of times across SE and I do not relish the prospect of editing them all. I'm still holding out for SE doing an automated replacement, which they won't do since they didn't even do it when all the Java documentation moved. – Gilles 'SO- stop being evil' Mar 07 '16 at 22:01