I have a shell script, /usr/bin/joevpn, which does a quick VPN connect. Basically (HOST and DOFIL are defined above and are correct. I just did not list them here) case "$1" in start) date > $DOFIL while [ -f $DOFIL ] do echo y | /usr/local/bin/vpnclient connect $HOST sleep 10 done ;; # Reconnects in case of disconnect (in while loop) This works. And in /etc/init.d I have a runjoevpn (which linked to /etc/rc5.d/S99runjoevpn). It works like the others. Below, $1 is checked (not shown here for brevity) and if it is "start" then start below is called: start() { date >> /root/joe.log /usr/bin/joevpn start & RES=$? return $RES } This all works and everything. I am just curious as to why when I do a ps I get this: /bin/bash /etc/rc5.d/S99runjoevpn Shouldn't that init script terminate since I have an "&" when I do the start() function above? No other rc5 stuff (i.e. tomcat for instance) shows up in the ps, though tomcat is running, it started up and returned. Is this OK or am I missing something?
tony.chamberlain at lemko.com wrote / nap?sal(a):> I have a shell script, /usr/bin/joevpn, which does a quick VPN > connect. Basically (HOST and DOFIL are defined above and are correct. > I just did not list them here) > > case "$1" in > > start) > date > $DOFIL > while [ -f $DOFIL ] > do > echo y | /usr/local/bin/vpnclient connect $HOST > sleep 10 > done > ;; > # Reconnects in case of disconnect (in while loop) > This works. And in /etc/init.d I have a runjoevpn (which linked to > /etc/rc5.d/S99runjoevpn). It works like the others. Below, $1 is checked > (not shown here for brevity) and if it is "start" then start below is > called: > > start() { > date >> /root/joe.log > /usr/bin/joevpn start & > RES=$? > return $RES > } > > This all works and everything. I am just curious as to why when I do > a ps I get this: > /bin/bash /etc/rc5.d/S99runjoevpn > > Shouldn't that init script terminate since I have an "&" when I do the > start() function above? No other rc5 stuff (i.e. tomcat for instance) > shows up in the ps, though tomcat is running, it started up and returned. > Is this OK or am I missing something? > >Because you start it each 10 seconds and because of while construction the start script NEVER end
tony.chamberlain at lemko.com wrote:> > start() { > date >> /root/joe.log > /usr/bin/joevpn start & > RES=$? > return $RES > } > > This all works and everything. I am just curious as to why when I do > a ps I get this: > /bin/bash /etc/rc5.d/S99runjoevpn > > Shouldn't that init script terminate since I have an "&" when I do the > start() function above? No other rc5 stuff (i.e. tomcat for instance) > shows up in the ps, though tomcat is running, it started up and > returned. Is this OK or am I missing something?The "&" doesn't terminate anything. It simply moves the process to the background and leaves it attached to the parent process. The parent process cannot exit until all of its child processes exit. What you are looking for is this: start() { date >> /root/joe.log nohup /usr/bin/joevpn start & RES=$? return $RES } The "nohup" command will detach the joevpn process from the parent and allow the parent process to exit. -- Bowie