Autostart/stop your application servers on Linux (RHEL), init.d,rc.d

Share on:

This is one of these posts, for me as I call them. A log of helpfull tips during work that might prove handy in the future.

So, I am doing lots of Oracle Weblogic configuration on these recent weeks, I needed to make my server instances auto-start and stop along with the operating system, RedHat Enteprise Linux that is. My linux skills are not at the level of Administration, but with a bit of googling and some tips of a colleague of mine - I devised a set of 5-6 steps steps.

  1. You need to have shell scripts ready that must follow the init.d convention (that would be accepting start / stop parameters etc.)
1./startMyWebLogic start
  1. Copy the scripts to /etc/init.d/ folder
  2. Check which is the default run level of your Linux server by typing
1cat /etc/inittab

That would print lots of details but at some point you see a line with the initdefault level, like below:

1id:5:initdefault:

That means thar run level 5 is the default.

  1. Browse to the specific run level directory
1cd /etc/rc5.d
  1. Create sym links on this folder, pointing to your original script, by following the init.d naming convention, SNameOfscript (for starting the service) and KNameOfScript for shutting down the service. S stands for start and K for kill, the priority is the order (1-99) that you want your scripts to be executed, if it something like 99 you are indicating that you want your scripts to be executed by the system last in the row. This is what I am doing for my server instances, just to make sure that the system has properly initialized every resource is needed
1ln -s /etc/init.d/startMyWebLogic.sh /etc/rc5.d/S99StartMyServer
2ln -s /etc/init.d/startMyWebLogic.sh /etc/rc5.d/K99StopMyServer

That's it!