• We did not send an email asking for donations - please read this post.

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
1,914
Reaction score
1,320
Credits
14,222
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

Active Member
Joined
Apr 15, 2022
Messages
263
Reaction score
163
Credits
2,421
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
7,790
Reaction score
6,615
Credits
28,677
Moving this to Command Line

Cheers

Wizard
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top