1

I would like to find all of the PIDs of processes which are not associated with a terminal.

When I do the ps aux | less command, I see in the TTY field a lot of processes with ? character

I would like to get those processes ID, is there a way to do that with pgrep?

I tried looking at the documentary over here https://www.freebsd.org/cgi/man.cgi?query=pgrep&sektion=1 but it's not very clear...

1

I don't think you can do this with pgrep. You can do it with ps.

ps -e -o pid= -o tty= | awk '$2 == "?" {print $1}'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.