Discovering a process run in the past

LuckyLuke93

New Member
Joined
Aug 31, 2022
Messages
5
Reaction score
0
Credits
53
Suppose that a random process starts at time X and ends at time X + 5 seconds... Is there a way to discover the TID, PID, and name of process for instance at time X+6 seconds? I would like to get the same informations given by ps
 


D

Deleted member 108694

Guest
On Linux with the ps from procps(-ng) (and most other systems since this is specified by POSIX):

Code:
ps -o etime= -p "$$"

Where $$ is the PID of the process you want to check. This will return the elapsed time in the format [[dd-]hh:]mm:ss.

Or, with newer versions of the procps-ng tool suite (3.3.0 or above) on Linux or on FreeBSD 9.0 or above (and possibly others), use:

Code:
ps -o etimes= -p "$$"

Have a look here - https://www.ibm.com/docs/en/aix/7.1?topic=p-ps-command
 
OP
L

LuckyLuke93

New Member
Joined
Aug 31, 2022
Messages
5
Reaction score
0
Credits
53
On Linux with the ps from procps(-ng) (and most other systems since this is specified by POSIX):

Code:
ps -o etime= -p "$$"

Where $$ is the PID of the process you want to check. This will return the elapsed time in the format [[dd-]hh:]mm:ss.

Or, with newer versions of the procps-ng tool suite (3.3.0 or above) on Linux or on FreeBSD 9.0 or above (and possibly others), use:

Code:
ps -o etimes= -p "$$"

Have a look here - https://www.ibm.com/docs/en/aix/7.1?topic=p-ps-command
if i don't know the process to monitor? I know that some process were in the past but i don't know what they are
 

osprey

Well-Known Member
Joined
Apr 15, 2022
Messages
1,120
Reaction score
1,090
Credits
10,669
Suppose that a random process starts at time X and ends at time X + 5 seconds... Is there a way to discover the TID, PID, and name of process for instance at time X+6 seconds? I would like to get the same informations given by ps
I stand to be corrected, but I'm not sure that this is possible without having some scripting to catch processes and log them. Usually when a process is run, it's PID becomes visible in /proc, but once it's finished, it's PID disappears and becomes unavailable so far as I can make out. A script that runs as a daemon though could catch everything if that's what you're after.
 

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
9,186
Reaction score
8,138
Credits
39,448
Moving this to Command Line

Cheers

Wizard
 

Members online


Top