Get the time spent by a process on Linux
I want to measure the time it takes to backup a PostgresSql database, I know I can do time pg_dump ....
, but what if I already launched the pg_dump command?.
The process already took more than half an hour, and I don't want to break it right know. I'm pretty sure it will take one more hour (and I'll be at home at that time). I would like to know tomorrow how much time it took.
Solution 1:
You are writing this to file, do you? File modification time would be your answer.
Solution 2:
Just show start time
ps -ax -o cmd,lstart | grep pg_dump
Or timestamp
ls --time-style=+%s -ld /proc/PROCESS_PID
Or secs elapsed
ls --time-style=+%s -ld /proc/PROCESS_PID | cut -d " " -f6 | \
xargs echo "`date +%s` - $1" | bc