I have this command launched in a bash script:
rsync -av $sourcedir/ $destdir/
how do I store the PID for that specific command in a variable in the same script?
i tried with:
rsync -av --stats $sourcedir/ $destdir/ && pid=$(echo $$)
but the pid reported for that operation in the log file differs from the one printed out echoing $pid
thanks for any help!
Note
&usage here. You run commands in parallel.If you make
rsync && pid=$!, it is wrong, because the command (rsync) is already finished at the point where you make the assignment (pid=$!), so it is make no sense to save its pid in a variable for obvious reasons.