Results 1 to 7 of 7

Thread: pstree details on command output

  1. #1

    Default pstree details on command output

    I have one terminal window open and enter superuser mode.

    Code:
    #pstree -hp | grep konsole
               |                |-konsole(12888)-+-bash(12891)---su(14410)---bash(14413)-+-grep(14463)
               |                |                |-{konsole}(12889)
               |                |                `-{konsole}(12890)
    I need to understand the details in this output. First, why are there more than one kconsole? Second, the details of the connections here, break it down.

    FYI, I'm learning scripting as write code.

    Thanks.

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    31,311

    Default Re: pstree details on command output

    From
    Code:
    man pstree
    Child threads of a process are found under the parent process and are shown with the process name in curly braces, e.g.

    icecast2---13*[{icecast2}]
    BTW, do you ever read man pages before you come here?

    PS.
    Apparently xterm does not use threading. Thus when this confuses you, you could use xterm instead of konsole (or maybe another terminal emulator).
    Henk van Velden

  3. #3
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    5,046

    Talking Re: pstree details on command output

    Quote Originally Posted by lord_valarian View Post
    First, why are there more than one kconsole?
    In the Konsole window, you could have simply hit F11 and then, executed “pstree -hp” …
    • On this system Akonadi and Firefox and MariaDB all have a number of processes running …
    • “ps -ejH -u «your username»” will also output your process trees …


    Understanding UNIX® and Linux processes is part of the Process Management skill needed by System Programmers.
    • Yes, UNIX® and Linux System Administrators also need some Process Management knowledge but, not to the same depth.
    • The Linux Foundation Certified System Administrator (LFCS) material has this entry: <https://www.linux.org/threads/lfcs-l...agement.28779/>.
    • There are also commercial tutorials explaining Linux processes – simply search for “Linux Process Managment” in DuckDuckGo …

  4. #4

    Default Re: pstree details on command output

    [QUOTE=hcvv;2936907]From
    Code:
    man pstree
    BTW, do you ever read man pages before you come here?

    Yes and often online pages. The manual pages are often not enough. Programmers and script writers often not great at writing docs, including myself.

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    31,311

    Default Re: pstree details on command output

    I admit that a man page is not a good documentation about a product, but most descibe in formal language waht it does and what options exist. And what I showed you was simply to be found there. My questions is of course: why could I find that in two minutes where you failed to see it?
    Henk van Velden

  6. #6
    Join Date
    Jun 2008
    Location
    East of Podunk
    Posts
    33,387
    Blog Entries
    15

    Default Re: pstree details on command output

    Quote Originally Posted by lord_valarian View Post
    I have one terminal window open and enter superuser mode.

    Code:
    #pstree -hp | grep konsole
               |                |-konsole(12888)-+-bash(12891)---su(14410)---bash(14413)-+-grep(14463)
               |                |                |-{konsole}(12889)
               |                |                `-{konsole}(12890)
    I need to understand the details in this output. First, why are there more than one kconsole? Second, the details of the connections here, break it down.

    FYI, I'm learning scripting as write code.

    Thanks.
    Hi
    You might want to look at pidof as well.....

    Code:
    pstree -hp `pidof tilda`
    
    tilda(2016)─┬─bash(16952)───pstree(30340)
                ├─bash(27996)
                ├─bash(30163)
                ├─{tilda}(2084)
                ├─{tilda}(2088)
                └─{tilda}(30164)
    The above tells me I have tilda running and three subprocesses which indicate three tabs open, it will disappear since the process may sleep....

    If your wanting to control a script, look at run options and creating a pid file...

    This is one I use for starting/stopping virtualradar (ADSB tracking);

    Code:
    cat bin/virtualradar
    
    #!/bin/bash
    
    # This program is free software; you can redistribute it and/or modify it
    # under the terms of the GNU Lesser General Public License as published by
    # the Free Software Foundation; either version 2.1 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful, but
    # WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    # Lesser General Public License for more details.
    #
    # Copyright (C) 2018-2020 Malcolm Lewis <malcolmlewis@opensuse.org>
    
    # Description: Script to start the Virtual Radar Service
    # Version: 0.0.1
    # Date: 11th February, 2018
    
    case "$1" in
        start)
            test ! -f /tmp/vrs.lock || { echo "Virtual Radar is already running...";
           if [ "$1" = "stop" ]; then exit 0;
           else exit 6; fi; }
            VRS_START=`date +\%m%d%y%H%M%S`
            echo "========" $VRS_START "========" > /tmp/virtualradar.log
            /usr/bin/mono /data/applications/VirtualRadar/VirtualRadar.exe -nogui >> /tmp/virtualradar.log &
        echo "** Success, Virtual Radar has been started and lockfile created... **"
            lockfile -r 0 /tmp/vrs.lock
        ;;
        stop)
            test -f /tmp/vrs.lock || { echo "Virtual Radar is already stopped...";
           if [ "$1" = "stop" ]; then exit 0;
           else exit 6; fi; }
            VRS_PID=`pgrep -f VirtualRadar.exe`
            kill -n 9 $VRS_PID
        rm -f /tmp/vrs.lock
        echo "Virtual Radar stopped..."
        ;;
           *)
        echo "Usage: $0 {start|stop}"
        exit 1
        ;;
    esac
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  7. #7
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    5,046

    Wink Re: pstree details on command output

    Quote Originally Posted by lord_valarian View Post
    Programmers and script writers often not great at writing docs, including myself.
    The original UNIX® man pages were written by Bell Labs scientists, who were used to writing research papers for publication by organisations such the IEEE …
    • Yes, the text often has to be read as if it is a scientific paper – which is not easy for the non-scientists on this planet – IOW: the majority …

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •