• Re: Basic ps Tips

    From Joerg Mertens@21:1/5 to Lawrence D'Oliveiro on Mon Aug 5 21:29:42 2024
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 4 Aug 2024 13:01:25 +0200, Joerg Mertens wrote:

    You can find the relevant commit message under
    http://cvsweb.openbsd.org/src/bin/ps/ps.c ...

    Why are they still using CVS? And not HTTPS?

    I know that both topics have been discussed on the OpenBSD `misc´
    mailing list (probably more than once) but this was some time ago
    and I did not pay much attention. If you search the list archive
    you should be able to find some answers.

    Regards

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to joerg-mertens@t-online.de on Mon Aug 5 19:34:31 2024
    In article <v8r977$10rjj$1@jmertens.eternal-september.org>,
    Joerg Mertens <joerg-mertens@t-online.de> wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 4 Aug 2024 13:01:25 +0200, Joerg Mertens wrote:

    You can find the relevant commit message under
    http://cvsweb.openbsd.org/src/bin/ps/ps.c ...

    Why are they still using CVS? And not HTTPS?

    I know that both topics have been discussed on the OpenBSD `misc
    mailing list (probably more than once) but this was some time ago
    and I did not pay much attention. If you search the list archive
    you should be able to find some answers.

    I think the whole point of the BSDs is to be retro.

    If they wanted to be modern, they'd be Linux.

    --
    In Usenet, as in life, as you go through it, you will run into lots of nonsense.
    Each time, you will have to decide from the following courses of action:
    1) Argue with it or 2) Ignore it.
    Experience shows that the later course is usually the best.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Weisgerber@21:1/5 to Lawrence D'Oliveiro on Mon Aug 5 21:50:35 2024
    On 2024-08-04, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    http://cvsweb.openbsd.org/src/bin/ps/ps.c ...

    Why are they still using CVS? And not HTTPS?

    The second question is counterfactual:
    https://cvsweb.openbsd.org/

    --
    Christian "naddy" Weisgerber naddy@mips.inka.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Tue Jul 30 20:43:52 2024
    On Sat, 27 Jul 2024 00:40:49 -0000 (UTC), I wrote:

    Another useful command to use with ps is pgrep(1) <https://man7.org/linux/man-pages/man1/pgrep.1.html>

    If you are expecting more than one process to match your criteria, it
    is easy enough to use the “-d,” option to comma-separate them. Then the output becomes acceptable to the “-p” option in ps, e.g.

    ps -p$(pgrep -d, bash) -wwo pid,ppid,lstart,tty,etime,cmd

    to report all the bash sessions I have running (quite a lot). The “ww”
    says not to truncate the output, which is handy for long command lines.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jerry Peters@21:1/5 to Lawrence D'Oliveiro on Fri Aug 2 00:19:58 2024
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sat, 27 Jul 2024 00:40:49 -0000 (UTC), I wrote:

    Another useful command to use with ps is pgrep(1)
    <https://man7.org/linux/man-pages/man1/pgrep.1.html>

    If you are expecting more than one process to match your criteria, it
    is easy enough to use the ???-d,??? option to comma-separate them. Then the output becomes acceptable to the ???-p??? option in ps, e.g.

    ps -p$(pgrep -d, bash) -wwo pid,ppid,lstart,tty,etime,cmd

    to report all the bash sessions I have running (quite a lot). The ???ww??? says not to truncate the output, which is handy for long command lines.

    Or just use ps -C <command>:

    ps -p$(pgrep -d, bash) -wwo pid,ppid,lstart,tty,etime,cmd
    PID PPID STARTED TT ELAPSED CMD
    1332 1327 Thu Jul 18 10:12:28 2024 pts/1 14-10:02:20 bash
    2019 2018 Thu Jul 18 20:20:31 2024 pts/3 13-23:54:17 bash
    2237 2236 Thu Jul 18 20:39:49 2024 pts/4 13-23:34:59 bash
    10821 10820 Sat Jul 20 14:45:57 2024 pts/6 12-05:28:51 bash
    20342 20341 Wed Jul 31 09:58:54 2024 pts/7 1-10:15:54 bash

    ps -C bash -wwo pid,ppid,lstart,tty,etime,cmd
    PID PPID STARTED TT ELAPSED CMD
    1332 1327 Thu Jul 18 10:12:28 2024 pts/1 14-10:02:35 bash
    2019 2018 Thu Jul 18 20:20:31 2024 pts/3 13-23:54:32 bash
    2237 2236 Thu Jul 18 20:39:49 2024 pts/4 13-23:35:14 bash
    10821 10820 Sat Jul 20 14:45:57 2024 pts/6 12-05:29:06 bash
    20342 20341 Wed Jul 31 09:58:54 2024 pts/7 1-10:16:09 bash

    Does noone know about -C? I keep seeing things like 'ps -ef | grep
    <something> in scripts to see if <something is running, rather than
    using 'ps -C'.

    Jerry

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Jerry Peters on Fri Aug 2 02:15:37 2024
    On Fri, 2 Aug 2024 00:19:58 -0000 (UTC), Jerry Peters wrote:

    Or just use ps -C <command>:

    Neat. But note this <https://manpages.debian.org/1/ps.1.en.html>:

    -C cmdlist
    Select by command name. This selects the processes whose
    executable name is given in cmdlist. NOTE: The command name is not
    the same as the command line.

    That might matter in some cases.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Sat Jul 27 00:40:49 2024
    One look at the man page for ps(1)
    <https://manpages.debian.org/1/ps.1.en.html> and you see all the
    different traditional option syntaxes it tries to be compatible with.
    The BSD style doesn’t even prefix options with dashes, which can lead
    to ambiguities and is best avoided. If this is what you’re used to,
    try to wean yourself off it.

    To list some useful info about all processes, you can do

    ps -ef

    or, for even more info, try

    ps -eF

    One thing I find annoying about this it reports less precision in
    process start times for long-running processes. To get around this, you
    can use a custom format. For example

    ps -eo pid,ppid,lstart,tty,etime,cmd

    shows some similar info to the default “-f” format, but always includes start time and elapsed time to the nearest second, regardless of how
    long the process has been running.

    Another useful command to use with ps is pgrep(1) <https://manpages.debian.org/1/pgrep.1.en.html>, which lets you filter processes to get information for according to various criteria. Or you
    could just use grep(1) on the output from ps, as I suspect a lot of
    people do. ;)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rene Kita@21:1/5 to Jerry Peters on Sat Aug 3 07:08:50 2024
    Jerry Peters <jerry@example.invalid> wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sat, 27 Jul 2024 00:40:49 -0000 (UTC), I wrote:
    [...]
    ps -p$(pgrep -d, bash) -wwo pid,ppid,lstart,tty,etime,cmd

    to report all the bash sessions I have running (quite a lot). The ???ww??? >> says not to truncate the output, which is handy for long command lines.

    Or just use ps -C <command>:
    [...]
    Does noone know about -C? I keep seeing things like 'ps -ef | grep <something> in scripts to see if <something is running, rather than
    using 'ps -C'.

    I did not know about it.

    The man page on OpenBSD does not mention -C, but calling 'ps -C' does
    not give an error. But:
    #v+
    $ ps -C ksh
    ps: /dev/mem: Permission denied'
    #v-

    Dunno what to make out of it, but apparently one reason to use grep
    instead of -C is portability.

    Jerry
    Rene

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)