So basically I have multiple users on my system and I want to determine how much CPU time they spend while being logged in into their shell and running different commands. I have a script which knows the PID of the shell they are logged in with. I must be able to probe the value regularly so I can't simply run the shell in time(1) or something like that.
I have glanced at /proc/$pid - anyone knows of a good value (or combination of values) there I could use? Maybe there's some kernel module for this?
An acceptable solution to my problem would allow querying init (the process with pid = 1) and find the total CPU time the entire system has used so far.