Operating System - Linux
1752770 Members
5663 Online
108789 Solutions
New Discussion

Re: Shutdown script to stop a application service

 
basant
Frequent Advisor

Shutdown script to stop a application service

Dear frieds
 
I expect your help in writing a script on rhel5 for below requirement.
 
On server nxETLd21, please ensure the Informatica services are automatically halted if the server is shut down.
The command to halt Informatica services is:
/eai/apps/informatica/PowerCenter/server/tomcat/bin/infaservice.sh shutdown
Please add the above command to the relevant OS shutdown script.

 

Basant

Basant Sharma
1 REPLY 1
Matti_Kurkela
Honored Contributor

Re: Shutdown script to stop a application service

In a RHEL5 system, there is a template for startup/shutdown scripts at:

/usr/share/doc/initscripts-<version>/sysvinitfiles

 

The file contains explanations and an example script: you'll only need to replace the parts within <angle brackets> with the commands you want. For example, here is the part that actually stops the application:

stop() {
        echo -n "Shutting down <servicename>: "
        <stop daemons, perhaps with the killproc function>
        rm -f /var/lock/subsys/<servicename>
        return <return code of stopping daemon>
}

 You would replace the <servicename> with the name of your application (which should be the same as the name of the script), and the <stop daemons, perhaps with the killproc function> part with the command given to you:

stop() {
        echo -n "Shutting down informatica: "
        /eai/apps/informatica/PowerCenter/server/tomcat/bin/infaservice.sh shutdown
        RESULT=$?
        rm -f /var/lock/subsys/informatica
        return $RESULT
}

 

If you don't actually need to start the application service, you can place a command that does nothing (or just outputs a message) in the place of the application start-up command.

 

You should also write the tags section at the beginning of the script, for example:

# chkconfig: 345 99 01
# description: This is the shutdown script for Informatica.

 (the tags section is explained at the end of the 'sysvinitfiles' file.)

 

Then save the completed script to /etc/init.d/informatica (or whatever you chose as the service name), and run "chkconfig --add informatica" to automatically create the needed links in the /etc/rc[0-6].d directories.

MK