Bug 192573 - [PATCH] Add ps(1) option: Print process start time in seconds since 1970
Summary: [PATCH] Add ps(1) option: Print process start time in seconds since 1970
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
Depends on:
Reported: 2014-08-11 08:11 UTC by Dave Eddy
Modified: 2014-08-19 06:29 UTC (History)
1 user (show)

See Also:

code patch for ps(1) (2.04 KB, patch)
2014-08-11 08:11 UTC, Dave Eddy
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Eddy 2014-08-11 08:11:37 UTC
Created attachment 145651 [details]
code patch for ps(1)

This patch adds a field (sstart) to ps(1) to print the time, in seconds since January 1st 1970, when a process started.

On Solaris (and the same works on Linux I believe), you can stat(2) /proc/<pid> and inspect the mtime of the directory to determine this information, however on BSD (1) /proc doesn't set the mtime on these directories and (2) /proc is most-likely going to be removed in future releases.


Simple example useful for scripting

$ ./ps -p $$ -o sstart=

All "started" fields currently available for the current process

$ ./ps -p $$ -o start,lstart,sstart
10:07PM Sun Aug 10 22:07:04 2014 1407708424

`sstart` is the most convenient for scripting purposes.