I need a linux / unix command that will execute another command and write the PID of the command it executes to a file... is there such a command?
I am not looking for any scheme that puts processes in the background and leverages the shell var
Assume the command I am looking for is
execwritepid. I need to be able to call:
execwritepid -e "/usr/bin/script -f sometext.log" -f /var/log/script.pid
Such that the PID of
script -f sometext.log is written to
script is the the command I'm executing.
The explicit suggestion, based on Daniel Pittman's answer is:
bash -c 'echo $$ > /var/log/script.pid && exec /usr/bin/script -f sometext.log'