Getting Process CPU Time from Command Line
/usr/bin/top -b -n 1 -p <pid> | tail -1 | awk '{print $9}'
EXAMPLES
-------------------
/usr/bin/top -b -n 1 -p 26769
top - 18:09:25 up 10 days, 23:26, 1 user, load average: 1,12, 1,19, 1,18
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
%Cpu(s): 5,5 us, 6,5 sy, 0,1 ni, 87,3 id, 0,5 wa, 0,0 hi, 0,0 si, 0,0 st
KiB Mem : 16100960 total, 560284 free, 7193420 used, 8347256 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 8405000 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
26769 root 20 0 1703524 663864 16856 R 140,0 4,1 286:02.52 qemu-system-x86
-------------------
/usr/bin/top -b -n 1 -p 26769 | tail -1 | awk '{print $9}'
113,3