Re: Need help with rc startup
From: Ed Brown (ebrown_at_computer-systems.com)
Date: 07/08/03
- Next message: LHradowy: "Re: tar question"
- Previous message: Stefan Marquardt: "DTC16RX (diag)"
- In reply to: Ed Brown: "Need help with rc startup"
- Next in thread: decourl_at_cs.sunyit.edu: "Re: Need help with rc startup"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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
- Next message: LHradowy: "Re: tar question"
- Previous message: Stefan Marquardt: "DTC16RX (diag)"
- In reply to: Ed Brown: "Need help with rc startup"
- Next in thread: decourl_at_cs.sunyit.edu: "Re: Need help with rc startup"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|