What you can try to use a combination of grep and sed in a shell script to get the value of PID from your txt file.
#!/bin/bash grep -o 'pid: [0-9]\+' /tmp/log.txt | while read -r line; do echo "$line" done