LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Start-Up/Shutdown Script (https://www.linuxquestions.org/questions/linux-newbie-8/start-up-shutdown-script-231019/)

ptreves 09-15-2004 03:35 PM

Start-Up/Shutdown Script
 
Hello,

Working on a Red Hat Enterprise 3 (ES) server, I want to lauch a number of application at start-up time and close them in case of a server shutdown.

In what file should I add these start-up commands and where should such a file be located ?

PT

PS: I have a Database startup/shutdown script located in /etc/init.d/dbora.
I want to do the same with a few other applications.

scottman 09-15-2004 04:27 PM

You should be able to put any script you write in /etc/init.d and have it loaded
on startup, and stopped on shutdown. You just need to use a case statement
to make it accept start, and stop. You can then set all your
startup commands to be executed when it recieves the start command. To add
commands for shutdown, have them under your stop command.

The reason this works is that /etc/rc.d/rc (on my Fedora system)
executes these scripts with a start or stop command, depending on
startup or shutdown. Most allow restart, reload, or other commands.

Here is an incomplete example, if you look at scripts in that file, you will
see that most adhere to certain standards, or are just function files.

Code:

#!/bin/bash
case $1 in
        start)
                STARTUP COMMAND1
                STARTUP COMMAND2
                STARTUP COMMAND3
        ;;
        stop)
                SHUTDOWN COMMAND1
                SHUTDOWN COMMAND2
                SHUTDOWN COMMAND3
        ;;
 esac

You could also add your commands to an existing script that gets executed.

/etc/rc.d/rc.local is also common place to add startup commands


All times are GMT -5. The time now is 05:37 PM.