0

I experience quite a bit of fan activity on my laptop, even the machine should be idle. When I take a look at my processes with top I have a pgrep process appear once in a while, taking some CPU. It is run as root user. Does anyone know what this is for? Is it something to be aware of, or is it just a normal system routine?

enter image description here

  Operating System: Debian GNU/Linux bullseye/sid
            Kernel: Linux 5.6.0-2-686-pae
      Architecture: x86

I run a while true; do pgrep -au root | grep pgrep; done loop to see when it is launched. The log looks like this:

22713 pgrep -n startx
22713 pgrep -n startx
22767 pgrep -n startx
22767 pgrep -n startx[...]

is there a way I can see what initiates the process?


Update: running the script from @hauke-laging I can see that /etc/acpi/power.sh seems to be the parent process:

-------------------------
10359 10358 root     root     pgrep -n startx
parent process:
10358  5645 root     root     /bin/sh /etc/acpi/power.sh

here it is:

#!/bin/sh

test -f /usr/share/acpi-support/key-constants || exit 0

. /usr/share/acpi-support/power-funcs
. /usr/share/acpi-support/policy-funcs

if { CheckPolicy || CheckUPowerPolicy; }; then
    exit
fi

cat /usr/share/acpi-support/power-funcs | grep pgrep there we go:

startx=$(pgrep -n startx || :)

1 Answer 1

2

Change the awk variables to root and pgrep.

$ /bin/ps -eo pid,ppid,user,euser,args |
    awk -v user=hl -v procname=kwalletd5 '{ a[$1]=$0; }; '\
'( $3==user || $4==user ) && $5 ~ procname '\
'{ print "-------------------------"; print; print "parent process:"; print a[$2]; }'

-------------------------
 4730  2725 hl       hl       /usr/bin/kwalletd5
parent process:
 2725     1 hl       hl       /usr/lib/systemd/systemd --user
-------------------------
30655     1 hl       hl       /usr/bin/kwalletd5
parent process:
    1     0 root     root     /usr/lib/systemd/systemd --switched-root --system --deserialize 31
1
  • Awesome command, THX a lot! the parent process is /etc/acpi/power.sh
    – nath
    Jun 11, 2020 at 0:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .