Re: Need help with rc startup

From: Ed Brown (ebrown_at_computer-systems.com)
Date: 07/08/03


Date: 8 Jul 2003 07:18:51 -0700

Never mind, I figured it out. I needed a nohup in the test_start procedure:

  su $TEST_USER -c "cd $TEST_HOME; nohup ./test.sh >>$TESTLOG 2>&1 &"

ebrown@computer-systems.com (Ed Brown) wrote in message news:<c3a6c5f4.0307071502.6c99d11c@posting.google.com>...
> I have a script I want to run at system bootup to start another script
> running in the background as another user. I have setup the config
> script in /etc/rc.config.d, the main script in /sbin/init.d, and a
> link to the script in /sbin/rc2.d. On bootup, the main script runs and
> executes the second script as a background process, but the second one
> then dies. It should continue to execute, as it contains a "while
> true" loop. I have basically the same script working fine on bootup on
> SCO Openserver and Solaris systems, but can't figure out why it won't
> keep running on HP-UX. My scripts and config info are included below.
> I've tried dropping the "su -c" stuff and letting it all run as root,
> but get the same results - the script test.sh runs for one loop, and
> then either dies or gets killed. Any suggestions would be appreciated!
>
> File /etc/rc.config.d/myscript:
>
> TEST_USER=tester
> export TEST_USER
> TEST_HOME=/usr/testdir
> export TEST_HOME
> TESTLOG=$TEST_HOME/test.log
> export TESTLOG
>
> ----------------------------------------------------
>
> File /sbin/init.d/myscript:
>
> #! /sbin/sh
> PATH=/usr/sbin:/usr/bin:/sbin
> export PATH
>
> test_start ()
> {
> su $TEST_USER -c "cd $TEST_HOME; ./test.sh >>$TESTLOG 2>&1 &"
> }
>
> test_stop ()
> {
> ps -fu $TEST_USER | fgrep -v "PID" | sort -r +4 | cut -c9-14 >
> /tmp/$$
> exec 4</tmp/$$
> while read PID <&4
> do kill -9 $PID
> done
> rm /tmp/$$
> }
>
> case "$1" in
> start_msg)
> echo Starting test daemons
> ;;
> stop_msg)
> echo Stopping test daemons
> ;;
> start)
> test_start
> ;;
> stop)
> test_stop
> ;;
> *)
> echo
> echo "Usage: myscript {start_msg|stop_msg|start|stop}"
> echo
> exit 1
> ;;
> esac
>
> exit 0
>
> ----------------------------------------------------
>
> File =/usr/testdir/test.sh:
>
> SLEEP_INTERVAL=540
> TESTPTH=/usr/testdir
> export TESTPTH SLEEP_INTERVAL
>
> while true
> do
> date >> $TESTPTH /test.out
> sleep $SLEEP_INTERVAL
> done
>
> ----------------------------------------------------
>
> My link:
>
> S910myscript -> /sbin/init.d/myscript



Relevant Pages

  • Re: How to Write an Infinite Loop that doesnt Die when Program Dies
    ... is a simpler way to start an infinite loop. ... Unfortunately, every time my web server dies, this script dies. ...
    (comp.unix.shell)
  • Re: Need help with rc startup
    ... Try changing your call to the inner script to an "at now" job. ... >true" loop. ... >then either dies or gets killed. ... made through NewsOne.Net violate posting guidelines, ...
    (comp.sys.hp.hpux)
  • Need help with rc startup
    ... I have a script I want to run at system bootup to start another script ... My scripts and config info are included below. ...
    (comp.sys.hp.hpux)
  • Re: Report in FM 6 or 7
    ... achieve this report format will have to be done via scripting. ... but they will simplify the script and Sort Order. ... End Loop ... The normal 'Dancer' field is used so that if there are more than one ...
    (comp.databases.filemaker)
  • Re: recreate database script not work
    ... I got a script which is supposed to regenerate database systax. ... REM gen_dbse_9.sql ... end loop; ...
    (comp.databases.oracle.server)