Shell Script Cache PID

Shell中擷取上一個執行指令的PID可以使用: $!

而如果需要擷取執行當下shell本身的PID可以使用:$$

範例:
#!/bin/bash
find . -name *.log -print > /tmp/log.txt &
# show the find pid
echo $! 
# show this shell's pid
echo $$

這個網誌中的熱門文章

Bash判斷參數是否存在

Node.js package : forever