“$$” is a useful Linux variable you could use in your script to get it’s PID. The “$$” variable always holds the PID of the executing process.

Why do you need it? Maybe to check if the script is already running? This is what I normally use it for.

Sample Script;

#!/bin/bash<br /> echo "My PID is $$"<br /> sleep 2

Sample Output;

[root@keke ~]# ./test1.sh<br /> My PID is 8909