I want to get the CPU and memory usage of a single process on Linux - I know the PID. Hopefully, I can get it every second and write it to a CSV using the \'watch\' command
ps axo pid,etime,%cpu,%mem,cmd | grep 'processname' | grep -v grep
PID - Process ID
etime - Process Running/Live Duration
%cpu - CPU usage
%mem - Memory usage
cmd - Command
Replace processname with whatever process you want to track, mysql nginx php-fpm etc ...