In Linux, you can use the
pgrep command to retrieve the process id (pid) associated with a unique process name. Here's how you can do it:
You can also use the
-f option with
pgrep to match the full command line instead of just the process name. This can be useful if you need to find a process running with specific arguments.
pgrep -f "python3 script.py"
This command will find the pid of a Python script named "script.py" running with the command "python3".
pgrep is available on most Linux distributions, but if it's not installed in your system, you can usually install it using the package manager specific to your distribution.