Page MenuHomeFreeBSD

ps(1): 24h timestamp for STARTED column
ClosedPublic

Authored by feld on Jan 23 2015, 5:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 25 2024, 10:28 PM
Unknown Object (File)
Mar 2 2024, 4:37 PM
Unknown Object (File)
Jan 4 2024, 10:22 PM
Unknown Object (File)
Dec 29 2023, 8:27 AM
Unknown Object (File)
Dec 19 2023, 11:59 PM
Unknown Object (File)
Dec 1 2023, 5:34 AM
Unknown Object (File)
May 21 2023, 12:13 PM
Unknown Object (File)
May 21 2023, 12:13 PM
Subscribers

Details

Summary

The output of ps oddly uses a 12h timestamp in the STARTED column. This has bothered me for some time, but a FreeBSD user complaining on IRC prompted me to investigate. It appears there are three different styles of output depending on the age of the process:

Here's some example output as it currently exists:

USER          PID  %CPU %MEM    VSZ   RSS TT  STAT STARTED        TIME COMMAND
root           11 100.0  0.0      0    16  -  RL   10Dec14 62211:31.52 [idle]
xymon        9138   0.0  0.2  20712  1868  -  I    10:21AM     0:00.01 vmstat 300 2
xymon       76893   0.0  0.2  12424  1196  -  Ss   Mon10AM     0:03.97 /usr/local/www/xymon/server/bin/xymonlaunch

The man page seems to have it documented incorrectly as well, but the main complaint here is the use of a 12h timestamp when a 24h is more appropriate and compatible with other systems (fake edit: Linux mainly, it seems).

Under the proposed changes the above would instead look like the following:

USER          PID  %CPU %MEM    VSZ   RSS TT  STAT STARTED        TIME COMMAND
root           11 100.0  0.0      0    16  -  RL   10Dec14 62211:31.52 [idle]
xymon        9138   0.0  0.2  20712  1868  -  I    10:21     0:00.01 vmstat 300 2
xymon       76893   0.0  0.2  12424  1196  -  Ss   Mon10     0:03.97 /usr/local/www/xymon/server/bin/xymonlaunch

I feel this is easier to parse, though I've never been a fan of the "if less than a week print WeekdayHour" format which I would prefer to remove because it's always been confusing to read, though it does give a bit more information at a glance if you actually understand what it's saying. This is still an improvement in my eyes, nonetheless.

This patch does entirely remove the ampm functionality (r73369 by ache and r113485 by charnier). Do we rely on T_FMT_AMPM for time formatting is globally? If not, it doesn't seem like a POLA violation. The 12h format does feel like an old, ignored POLA violation instead...

So as a result, this change does bring us to be more compatible with GNU/Linux's ps output as seen below:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  19352  1548 ?        Ss   Jan05   0:03 /sbin/init
root     26850  0.0  0.1 106480  7124 ?        Ss   08:20   0:00 sshd: a0s02t [priv]

...but GNU/Linux doesn't have the WeekdayHour format, so if we care enough for full compatibility it should be removed.

For the record, this would mean
FreeBSD uses: %H:%M, %a%H, and %e%b%y which seems more readable
OpenBSD uses: %l:%M%p, %a%I%p, and %e%b%y
NetBSD uses: %l:%M%p, %a%I%p, and %e%b%y
DragonFlyBSD uses: [identical to FreeBSD before this patch with the ampm code]
Linux uses: %H:%M and %b%d according to STIME in http://procps.cvs.sourceforge.net/viewvc/procps/procps/ps/output.c?revision=1.65&view=markup

I have not yet compared with the output of Solaris or any other *nix as I don't have access at the moment, but comments in the Linux procps code mention that Solaris has spaces in their output which isn't supposed to be allowed (by POSIX?)

I'm hoping this doesn't turn into a bikeshed, so feel free to tell me this is a terrible idea. :-)

I don't know who all should be added to reviewers, but trasz has made quite a few edits to this file.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

feld retitled this revision from to ps(1): 24h timestamp for STARTED column.
feld updated this object.
feld edited the test plan for this revision. (Show Details)
feld added a reviewer: trasz.
feld set the repository for this revision to rS FreeBSD src repository - subversion.
feld added a subscriber: brd.

Oh, and GNU/Linux's output for older processes is MonthDay (Jan05) vs FreeBSD's DayMonthYear (05Jan15) but I think ours is better :-)

trasz edited edge metadata.
This revision is now accepted and ready to land.Mar 15 2015, 12:17 PM
feld updated this revision to Diff 4254.

Closed by commit rS280171 (authored by @feld).