LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   Start-Up Script & Shutdown/Kill Script needed (https://www.linuxquestions.org/questions/red-hat-31/start-up-script-and-shutdown-kill-script-needed-880085/)

guggilamsandeep 05-11-2011 08:42 AM

Start-Up Script & Shutdown/Kill Script needed
 
Hi,

We have couple of application services on Red Hat Linux box. I am planning to have start up script, which will be executed when the server boots up and all the application services mentioned in the script should start after executing the script.

In the same way, a shut down script, which is executed when the server is shutting down and all my application services will stop while server is shutting down.

I have seperate team to deploy this. But we have to provide them the scripts. I am not gud at Linux. Could any one please sent me the sample script that acomplissh my requirements.

Just imagine the application services as below and give me sample script.

arcsight_oracle
arcsight_syslog
arcsight_ips

Thanks in advance

Thanks
Sandeep

SL00b 05-11-2011 08:58 AM

You don't want separate scripts for stopping and starting. You want to create one script, put it in /etc/init.d, and set it up for the proper runlevels with the chkconfig command.

A sample script would look something like this:

Code:

#! /bin/bash
#
# /etc/init.d/arcsight_oracle.sh

#
### BEGIN INIT INFO
# Provides:          arcsight_oracle
# Required-Start:    $remote_fs
# Required-Stop:    $remote_fs
# Should-Start:      $syslog
# Should-Stop:      $syslog
# Default-Start:    3 5
# Default-Stop:      0 1 2 6
# Short-Description: arcsight_oracle
# Description:      arcsight_oracle
### END INIT INFO

case "$1" in
  start)
        echo -n "Starting arcsight_oracle"
        /path/to/arcsight.startcommand arguments
        echo "."
        ;;
  stop)
        echo -n "Starting arcsight_oracle"
        /path/to/arcsight.startcommand arguments
        echo "."
        ;;
  *)
        echo "Usage: service arcsight_oracle {start|stop}"
        exit 1
esac

exit 0

Depending on how the dependencies are for those different applications, it may even make sense to put the start/stop commands for all of them in one script, instead of different scripts for each. This would allow you to start them in the right order.


All times are GMT -5. The time now is 12:19 PM.