RHEL server 6.6. - implementing application start and stop scripts into boot
we have Oracle Enterprise Manager and I have the scripts to start and stop its agent.
I want to implement these scripts into the proper RC levels at shutdown and startup.
Is CHKCONFIG used for this?
Responses
Create a symlink in the desired runlevel to point to the script. Provide location of the script and which run levels you want them to come up or shutdown.
Thanks
Sorry Arrey,
IMHO: That is not the best practise for a Red Hat system. running RHEL 6 or lower.
This is the way I would do it, to be compatible with Red Hat "boot scripts"
~ vi /etc/init.d/oracle_oem
~ #!/bin/bash
~ #
~ # oracle Start up the oracle software
~ #
~ # chkconfig: 2345 99 01
~ # description: Oracle Enterprise Manager start/stop script
~ #
~ #
~ # source function library
~ #
~ source /etc/rc.d/init.d/functions
~
~ RETVAL=0
~ prog="oracle_oem"
~
~ lockfile=/var/lock/subsys/$prog
~
~ start()
~ {
~ "start commands"
~ }
~
~ stop()
~ {
~ "stop commands"
~ }
~
~ restart()
~ {
~ stop
~ sleep 15
~ start
~ }
~
~ case "$1" in
~ start)
~ touch $lockfile
~ start
~ ;;
~ stop)
~ rm -f $lockfile
~ stop
~ ;;
~ restart)
~ restart
~ ;;
~ *)
~
~ echo $"Usage: $0 {start|stop|restart}"
~ RETVAL=2
~ esac
~ exit $RETVAL
~
==EOF==
~ chmod 755 /etc/init.d/oracle_oem
~ chkconfig oracle_oem on
Kind regards,
Jan Gerrit Kootstra
P.S. ~
The Linux Standards Base documents requirements for initscripts:
The chkconfig tool has its own runlevel format, but will prefer LSB format when a script contains both formats. These are described with examples on man chkconfig.
You should endeavour to write an LSB-compliant initscript. Look at some of the existing initscripts to get an idea of how they do it.
An initscript is very easy to get "working" but can be a surprisingly large job to get "right" under all conditions. For example, guard against running service foo start when the service is already started. When checking if your service is running, do you want to use a lockfile or do you want to check for a running PID?
If you have any configuration parameters, pass them off to /etc/sysconfig/scriptname or /etc/default/scriptname, then source that file from your script. This lets you update the script itself without losing your config.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
