How do I set a unix process to autorun in a particular run level?

2

I have a stand alone server application that I would like to run automatically when my red hat box starts up. My default run level is 5 but I want to make sure it works both in run level 3 & 5.

Answers appreciated!

Axxmasterr

Posted 2009-07-30T17:36:58.600

Reputation: 7 584

Answers

4

There's /etc/rc.d/rcX.d directory for each runlevel X. Symlink apropriate [S]tart and/or [K]ill scripts to /etc/rc.d/rc3.d/ and /etc/rc.d/rc5.d

The scripts are run as sorted by number. This way you can organize dependencies.

The scripts per se are in /etc/init.d/

Tadeusz A. Kadłubowski

Posted 2009-07-30T17:36:58.600

Reputation: 2 005

Also - on BSD (inherited by Slackware), runlevels are actually found in /etc/rc.d/rc.* - that is strictly a Debian/RH view of things. – new123456 – 2011-04-29T21:04:41.263

2

You can also use chkconfig

Example:

chkconfig [servicename] on

This normally actives the service on runlevel 3 and 5.

BinaryMisfit

Posted 2009-07-30T17:36:58.600

Reputation: 19 955

+1, I liked this when still using Red Hat / Fedora. It's not available on other distros than RH-based ones, is it? – Jonik – 2009-07-30T18:59:37.437

1It is available on Ubuntu and on Cent-OS. I use it regularly. – BinaryMisfit – 2009-07-30T19:04:17.360

Ah, so it seems; http://packages.ubuntu.com/jaunty/chkconfig. Cool!

– Jonik – 2009-07-30T19:08:39.300