LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   red hat startup scripts problem (https://www.linuxquestions.org/questions/linux-newbie-8/red-hat-startup-scripts-problem-69/)

tdavid6789 08-29-2000 09:08 PM

I'm familiar with making startup scripts in other unix platforms, but redhat 6.1 and 6.2 want to pass a start or stop command to the startup script. I have loaded a program that does not need the start and stop sent to it. The passing of the start kills the program. I just want to have a symbolic link to the programs executable run when the runlevel is reached. Any suggestions?

jeremy 08-30-2000 06:46 AM

First put a file in /etc/rc.d/init.d that looks like the following:
Code:

#!/bin/sh
# Startup script for program

# Source function library.
. /etc/rc.d/init.d/functions

case "$1" in
  start)
                echo -n  "Starting program: "
                daemon program
                echo
                ;;
       
  stop)
                echo -n "Shutting down program "
                killproc program
                echo
                ;;

  *)            echo "Usage: program {start|stop}"
                exit 1

esac

exit 0

Then make soft links to the startup file in the appropriate rcN.d directories, where N is the runlevel. NOTE: If you do not want the program to run as a damon then take out the word daemon before the program name.

[Edited by jeremy on 08-30-2000 at 08:17 AM]

tdavid6789 09-01-2000 07:16 PM

Thanks
 
Thanks I will try it soon!

tdavid6789 09-21-2000 09:38 AM

startup works but kill doesn't seem to work..
 
Hello,

I used your script and it works on startup just fine. I now have a problem with the kill scripts. I made a ln -s to rc3.d, rc0.d, and rc6.d and the target was K??programname. ?? being like 01. I want to kill my application before the machine kills the rest of the scripts.Nothing depends on them. I want the script to kill the program on halt, reboot. The startup is obviously only in rc3.d because runlevel 3 is my default. I don't see any thing on the screen saying it killed my program when I halt or reboot. I do see messages on startup. Do you have any ideas? Is linux wierd about using particular numbers in startup and kill scripts in the rc directories?

I appreciate your help.
Thank You Tom :)

jeremy 09-21-2000 09:53 AM

When the system changes runlevels it goes into the appropriate dir (we'll say /etc/rc.d/rc0.d for shutdown) and calls each script. If the filename is K99program it will call it with stop (./K99program stop). If the filename is S99program it will call it with start. The files are called in ascending order (starting with x00, ending with x99). You may want to change the echo in the stop case to "Shutting down programname" to make it more noticable.

ctdp 09-25-2000 09:09 PM

Run level 0 is halt and runlevel 6 is reboot. You will need to put your link to kill your program in the appropriate directory for these two runlevels to get it to work for both halt and reboot. Putting the kill link in runlevel 3 will not do anything for you. Also if you want the program to run while in X, you will need to put the start link in runlevel 5 also.


All times are GMT -5. The time now is 09:33 PM.