--- I have created my own local start up script that should run when the system is booted, but the commands contained therein do not seem to get started. Is this a simple shell script problem, or what? --- Summary: --- Use nohup on the command (or daemon) within the shell script. As well, allow the script to sleep before it exits. I haven't been able to try this out yet (on a reboot), but at least running it interactively works. --- Thanks to the following: Michael Matthews <matthewm_at_sgate.com> "Dr. Tom Blinn, 603-881-0646" <tpb_at_zk3.dec.com> m_beltramo_at_scomp1.sonda.cl (Marcelo Beltramo) Winfried Huber <win_at_tukan.ffb.eunet.de> joe_at_resptk.bhp.com.au Dougal Scott <dwagon_at_aaii.oz.au> Juergen Bock <FDV20_24_at_dbf-s1.dbf.ddb.de> Gerhard Kircher <kircher_at_edvz.tuwien.ac.at> Hellebo Knut <Knut.Hellebo_at_nho.hydro.com> Simon Tardell <tardell_at_particle.kth.se> --- Responses: --- From: Michael Matthews <matthewm_at_sgate.com> > #!/bin/sh Should probably be /sbin/sh for the statically linked sh, but that won't cause this problem unless your shared libraries are toast, in which case you've got far more things to worry about and you couldn't have gotten past bootup anyway. > # > # Set up local cusomizations in here. > # To be run as the last file on boot and the first on shutdown. > echo "Local customizations..." > case $1 in > 'start') > echo -n "Starting stats gathering: " > echo -n "iostat " > /usr/bin/iostat rz0 rz1 rz2 rz5 900 | logger -p local1.debug & make it /usr/bin/logger just to be safe > ;; > 'stop') > ;; > esac --- From: "Dr. Tom Blinn, 603-881-0646" <tpb_at_zk3.dec.com> Try putting a nohup at the beginning of this line: > /usr/bin/iostat rz0 rz1 rz2 rz5 900 | logger -p local1.debug & Also put in a little wait (sleep) before the script exits. --- From: m_beltramo_at_scomp1.sonda.cl (Marcelo Beltramo) Hi Rob: When you try to start a daemon from a script , for any reason DU finishes (or aborts, or something) the script before the daemon initializes. So, you have to run it with a "nohup" an put a sleep to dely the end of the script. I've had the same problem with the popd daemon and I solve it with the followin script: #!/sbin/sh PATH=/sbin:/usr/sbin:/usr/bin:/usr/lib/mh export PATH case "$1" in 'start') set `who -r` if [ $9 = "S" ]; then [ -f /usr/lib/mh/popd ] && { nohup /usr/lib/mh/popd -d -p 110 > /dev/null & echo "Post Office Protocol service started" } fi sleep 5 ;; 'stop') pid=`/bin/ps -e | grep popd | grep -v grep | \ sed -e 's/^ *//' -e 's/ .*//' | head -1` if [ "X$pid" != "X" ] then /bin/kill $pid fi ;; esac This one is working; you can use it for your daemon. --- From: "Dr. Tom Blinn, 603-881-0646" <tpb_at_zk3.dec.com> (AGAIN) > Why would I put it to sleep before exiting? The rumor has it that you want to give whatever you're running from the script time to get really started up before the initiating script dies. I don't claim to understand exactly why this works, but people swear by it as a technique. --- From: Winfried Huber <win_at_tukan.ffb.eunet.de> Hi Rob, 1. use absolute path names, e.g. /bin/logger instead of logger 2. make the shell tell you what it's doing: include "set -v" and "set -x" in your script. --- From: joe_at_resptk.bhp.com.au Hi, Try using the command 'nohup'. See 'man nohup'. An example: #!/bin/sh # # Set up local cusomizations in here. # To be run as the last file on boot and the first on shutdown. echo "Local customizations..." case $1 in 'start') echo -n "Starting stats gathering: " echo -n "iostat " /usr/bin/nohup /usr/bin/iostat rz0 rz1 rz2 rz5 900 | logger -p local1.debug & ;; 'stop') ;; esac You may have to redirect the output from 'nohup' ? --- From: Dougal Scott <dwagon_at_aaii.oz.au> The usual problem with scripts such as this, is they get sent signals which cause them to die. Try trapping signals in the script and seeing if it gets further. --- From: Juergen Bock <FDV20_24_at_dbf-s1.dbf.ddb.de> try nohup iostat ... --- From: Gerhard Kircher <kircher_at_edvz.tuwien.ac.at> Well here is my /sbin/init.d/local: #!/sbin/sh # PATH=/sbin:/usr/sbin:/usr/bin export PATH case "$1" in 'start') [ -x /usr/local/sbin/sshd ] && /usr/local/sbin/sshd echo "sshd - secure shell daemon" ;; 'stop') ;; *) echo "usage: $0 {start|stop}" ;; esac The differences are: 1) you are using /bin/sh instead of /sbin/sh and 2) you don't set PATH so echo might not be found. --- From: Hellebo Knut <Knut.Hellebo_at_nho.hydro.com> Try putting a 'nohup' in front of the '/usr/bin/iostat' line. --- From: Simon Tardell <tardell_at_particle.kth.se> No, but it is certainly a FAQ on this list. Your child processes are SIGHUP:ed when your script exits (sh(1)); try to start them with nohup, and, maybe, try to wait for a sec or two at the end of the script to give them proper time to start up. --- -- Rob Naccarato rob.naccarato_at_sheridanc.on.caReceived on Tue Feb 13 1996 - 16:31:26 NZDT
This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:46 NZDT