I need the pid for a process given its owner and its command. I can filter a process per user with "ps -u xxx" and its command by "ps -C yyy", but when I try "ps -u xxx -C yyy", they are combined using OR logic. I need AND logic. How can I accomplish this?
Linux – Can the Linux ps command output be filtered by user AND command
command-line-interfacelinuxscripting
Related Topic
- Linux – Check Environment Variables of a Running Process on Unix
- Linux – How to change the output line length from the “top” linux command running in batch mode
- Linux – How to prevent a user from login in, but allow “su – user” in Linux
- Linux – How to Get PID of Just Started Process
- Linux – How to run command as user who has /usr/sbin/nologin as Shell
- How to Run Complex Commands Using sudo Over SSH
- Linux – way in Linux where one non root user can check if another non root user is using OpenSSL or not without sudo permission
Best Answer
Use pgrep?
it returns just the pid (or pids, if more than one process matches).