There are some differences between the interactive shell and shell scripts of Linux, mainly because of the existence of a separate running process, so there is a difference between the acquisition process PID.
Interactive Bash Shell get process pid
#在已知进程名 (name), the interactive Shell gets the process PID in a number of ways, typically by using grep to get the PID method (add-v grep here to avoid matching to the grep process): Ps-ef | grep "Name" | Grep-v grep | awk ' {print $} ' #或者不使用 grep (where the initials are added [] to avoid matching to the process of awk itself): Ps-ef | awk '/[n]ame/{print $ ' #如果只使用 x parameter then the PID should be in the first position: PS x | awk '/[n]ame/{print $ ' #最简单的方法是使用 pgrep:pgrep-f name# If you need to find the PID and kill the process, you can also use pkill:pkill-f name# if it is an executable program, you can directly make With pidofpidof name
Learn the shell address
Https://www.yiibai.com/shell/unix-special-variables.html
Http://wiki.jikexueyuan.com/project/shell-learning/gorgeous-printf-output.html
Shell Get Process PID