On 02/10/2018 10:29 PM, Carlos E. R. wrote:
Is it possible to get the PID of the previous command launched and finished?
Example:
fetchmail .... echo "Posible PID of fetchmail was: $!"
Well, the value I get I know it was not the PID. The documentation says that "$!" gets the PID of the previously backgrounded process, so it is not what I want.
The crucial term for "$!" is: "background process". You send a process to background if you start it with "&" a the end. $ sleep 60 & $ echo $! 14100 So if you need the PID of the previously launched and finished process (whatever this may be good for), then you could e.g. do: sleep 10 & # send process to background pid=$! # get its PID wait $pid # wait for the process to terminate rc=$? # get the exit status of the process echo "PID: $pid, exit status: $rc" Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org