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
 


Lord Boltar

Well-Known Member
Joined
Nov 24, 2020
Messages
2,216
Reaction score
1,621
Credits
16,361
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
685
Reaction score
570
Credits
6,390
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
8,628
Reaction score
7,587
Credits
35,291
Moving this to Command Line

Cheers

Wizard
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Top