1

Using "$!" to get the PID of the Last Ran Backgroud Process

view story
linux-howto

http://www.unix.com – Hello All, I was looking into creating a script that would be used only to start a Daemon and create a lock file... F.Y.I. It's for Nagios' NRPE Daemon Plugin... Anyway when I run the command to start the Daemon (below): Code: /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d And try to get the PID of that Command just ran by adding this to the end of that line above: Code: ...-c nrpe.cfg & echo $! The PID it prints out is NOT the PID of the NRPE Daemon. Am I not using the "echo $!" correctly...? On one of the boxes im trying this on, which is SLES 1 (HowTos)