Setting up auto-startup when OS starts up or reboot on Linux

Hi,

Would like to configure auto-startup on few process on linux OS. Could you suggest detailed steps please

Scenario is, I have few applications running on Linux which has dependencies between them (Parent, child, grand child). So when OS reboots/starts....would like to
1. start  parent app first
2 wait for parent to be running, then start child app
3 wait for child to be running, then start grand-child app.

Also similar for graceful shutdown

Thanks in advance
enthuguyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

farzanjCommented:
What is your Linux distro?

You have to create a /etc/rc.d kind of script.  This would start it in the order you mentioned.  Will also shut in the correct order.
0
farzanjCommented:
Here is an example script for you.

http://forum.tinycorelinux.net/index.php?topic=4126.0
0
farzanjCommented:
Once you create the script and run it successfully as per your wishes, you will have to add a symlink of it in the folder of your run level like rc3.d or rc5.d.  This is done with a simple command but that command is different with different distributions.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

enthuguyAuthor Commented:
Hi Farzanj, Thanks for your quick comment.

To be precise...I run Oracle Enterprise Linux 5.x

Above sample script would work for me?
0
xtermCommented:
Create /etc/init.d/parentname
Create /etc/init.d/childname
Create /etc/init.d/grandchildname

Each of these should be set up to take the arguments "stop" or "start".

So /etc/init.d/parentname will start your parent app
And /etc/init.d/childname will start your child app
And /etc/init.d/grandchildname will start your grandchild app

If you don't have one created, simply go into /etc/init.d, do "ls -l" and find one of the smaller sized ones and copy/clone it for your own use.  They are quite simple.

Now that you have these created, you need to customize the order that they start up.

You will see each file in there has a line referencing "chkconfig" that looks something like this:

  chkconfig: 2345 55 25

The first argument are the run levels in which your script will run - you probably don't need to change this from 2345.

The 2nd and 3rd arguments are the startup and shutdown order respectively.

For your parent app you could put:

  chkconfig: 2345 55 25

And your child app:

  chkconfig: 2345 56 24

And grandchild app:

  chkconfig: 2345 56 23

This would start your parent app and then the child app and then your grandchild app, and then when you shut down the system it will terminate them in reverse order

After you've modified these, do:

  chkconfig --add parent
  chkconfig --add child
  chkconfig --add grandchild

Then when you do "chkconfig --list parent" (or the other two) it should say:

  parent            0:off   1:off   2:on    3:on    4:on    5:on    6:off

BTW, the system startup doesn't wait per se for applications to startup, it simply waits for the previous startup scripts to exit.  So if you want to be sure that one thing has started up fully prior to launching the next, you will want to not launch the parent into the background (aka, do not use the "&" character behind the command that starts it) or perhaps insert some sleep X lines to slow it down if need be.  Keep in mind though, that you could delay your system boot up if these processes are slow to start.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
farzanjCommented:
It should work for you.  If you include all the three processes in the same startup script, you will have the control over the start and end order of processes.
0
xtermCommented:
Sorry, grandchild app should have:

   chkconfig: 2345 57 23

You get the idea though :)
0
enthuguyAuthor Commented:
Awesome!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.