Getting Process Name from PID and Vice Verse
Sometimes we need to know the process name via the specific pid, and sometimes vice verse, especially when only allowing one process running, so it is necessary to know how to.
Table of Contents
Getting Process Name via PID
We could get process name easily by the following command
1 | ps -o comm= -p PID |
Getting PID for the Specific Command
On the other hand, somtimes we wanna know the pid of specific process, we can do as following
1 | pgrep command |
Allowing Only One Process Runnnig
Having only one process running and start a new one if not running
1 | pgrep command >/dev/null || command |
水水更健康"o((>ω< ))o"