Вы пытаетесь сопоставить параметры Linux ps
и имя поля с параметрами и ключевыми словами FreeBSD ps
: это одно из основных очевидных различий между Linux-подобной системой и BSD-системой.
Во-первых, параметр -e
во FreeBSD ps
означает «Также отображать среду» .
На самом деле вы хотите, чтобы отображались все процессы, то есть -ax
для FreeBSD;
-x
- отображать также процессы без управляющего терминала. (процессы ядра и демоны), и по умолчанию они не отображаются.
Относительно Linux ps
о выборе поля (из man ps
):
euser EUSER effective user name. This will be the textual user ID, if it can be obtained and the field width
permits, or a decimal representation otherwise. The n option can be used to force the decimal
representation. (alias uname, user).
ruser RUSER real user ID. This will be the textual user ID, if it can be obtained and the field width permits,
or a decimal representation otherwise.
suser SUSER saved user name. This will be the textual user ID, if it can be obtained and the field width permits,
or a decimal representation otherwise. (alias svuser).
fuser FUSER filesystem access user ID. This will be the textual user ID, if it can be obtained and the field
width permits, or a decimal representation otherwise.
f F flags associated with the process, see the PROCESS FLAGS section. (alias flag, flags).
comm COMMAND command name (only the executable name). Modifications to the command name will not be shown.
A process marked <defunct> is partly dead, waiting to be fully destroyed by its parent. The output in
this column may contain spaces. (alias ucmd, ucomm). See also the args format keyword, the -f option,
and the c option.
When specified last, this column will extend to the edge of the display. If ps can not determine
display width, as when output is redirected (piped) into a file or another command, the output width
is undefined. (it may be 80, unlimited, determined by the TERM variable, and so on) The COLUMNS
environment variable or --cols option may be used to exactly determine the width in this case. The w
or -w option may be also be used to adjust width.
label LABEL security label, most commonly used for SE Linux context data. This is for the Mandatory Access
Control ("MAC") found on high-security systems.
Из FreeBSD ps
руководство о выборе ключевого слова:
uid effective user ID (alias euid)
user user name (from UID)
ruid real user ID
ruser user name (from ruid)
svuid saved UID from a setuid executable
state symbolic process state (alias stat)
comm command
label MAC label
Там Нет очевидного эквивалента FreeBSD для fuser , поэтому давайте пропустим его.
Итак, в вашем случае это будет выглядеть так:
ps -axo user, ruser, svuid, state, comm, label | grep
Вам нужно отформатировать дату в формате ISO 8601.
$(date -Is)
I
для формата ISO, s
для даты и времени.
С GNUdate
:
$ date +%FT%T.%3N%:z
2017-06-30T13:00:54.566+01:00
С bash
встроенными функциями самое близкое, что вы можете получить, это:
$ printf -v date '%(%FT%T%z)T' -1
$ printf '%s\n' "${date%??}:${date: -2}"
2017-06-30T13:00:54+01:00
как bash
не поддерживает точность до доли секунды.
С последними версиямиzsh
:
$ zmodload zsh/datetime
$ strftime -s date '%FT%T.%3.%z'
$ printf '%s\n' $date[1,-3]:$date[-2,-1]
2017-06-30T13:00:54.566+01:00