PID output query

I recently got an update notification in POP OS and when I hit update within the GUI I got the message “Waiting for Package Manager”. Now a look on the Internet showed that this relates to locked apt process and is the same as “could not get lock” error. There were some articles on the internet with the best being the following which I followed and cleared my issue:

However in the article it states that using “ps aux | egrep -i apt” would produce all of the output for apt. (Now egrep is the same as grep -E but faster from what I have read.) Now when I did this I only got one PID. If I used grep -E I got a different PID and the same applied if I used “ps aux | egrep -i apt-get” or grep -E. I ended up with 4 different PIDs. And if I used sudo in front I got completely different PIDs again. Can somebody explain this action? Looking at the ps man page the aux indicates BSD format.

Anytime I’ve run into this, I just wait 30 seconds and try again and it usually works. IMHO, if you prefer to manage packages via the CLI, it’s probably best to disable the GUI update manager, otherwise you’ll compete with it every now and then.

The original issue came from the GUI but resolved via CLI. I think that it’s just one of those things that happens from time to time and I have been lucky not to get it before. (You learn from these sort of things happening.) In this case I left it more than a few seconds, more like a few minutes to retry. However the query I really had was why was I was getting different PIDs from the terminal depending on what I input, and only one PID at a time and not a series of PIDs. (Original posting has the inputs I used.)

Getting different PIDs based on the grep command, that doesn’t make sense to me - there has to be something else to it. Usually when PIDs change, I think of “flapping”, or a service failing and restarting itself again and again. Depending on what’s going on in the background, apt could be running multiple transactions in a process tree, and you’re seeing that tree differently based on the command you use to check it. Those are just guesses though, but I can’t think of another scenario that would cause that off the top of my head.