Creating a service on redhat linux / Oracle enterprise linux

Question

How to start a certain application automatically for example at startup of the machine, it is required to define it as a service.

Well ...

This can be achieved 4 rather easy steps:
  • Create a script that performs everything required to start and stop the application, including the setting of the environment;
  • Save the script in the /etc/init.d directory
  • Give the script the permissions to execute
    chmod u+x
  • install the service
    chkconfig --add
The tricks are inside the script.

Start and Stop logic in the script
When a service is started the start keyword is passed as parameter $1 to the script. When the service is stopped the stop keyword is passed.

Runlevel and Runorder arguments
In the script a lines identify at what runlevel and in which sequence the service should be started or stopped.
#chkconfig: 2345 80 05
This line is composed of the chkconfig keyword followed by three paramters:
  • the first indicates at what runlevels the service should be started
  • the second indicates what the priority is (scriptsequence) at startup
  • the third indicates the priority when stopping

Description of the service

To set the description of the service enter a line like the following in the script
#description: Oracle 8 Server


Further details

No comments: