Search code examples
bashscriptingpid

How can a Linux/Unix Bash script get its own PID?


I have a script in Bash called Script.sh that needs to know its own PID. In other words, I need to get PID inside Script.sh.

Any idea how to do this?


Solution

  • The variable $$ contains the PID.