bash script help

Trying to solve a problem here

Lets say that I have a linux script, that goes something like:

#!/bin/sh

while true
do
./commandline -opt1 -optN

sleep 30
done

I launch it like ./script &

I need to write the PID of the ./commandline process out to a file. THis process is long-running and so nothing past this line will execute unless it crashes.

I dont know how to make it write its pid to a pidfile! Help!

 

 

 

 

Top