Navigation Advertising

Next post

Post content

Run something when Linux boots

Linux

How to automatically run a command or program at Linux system start-up:

The file where boot process sequence is defined is: /etc/inittab
Log in as root, open it with a text editor, and locate a line similar to this:

# Default runlevel. (Do not set to 0 or 6 !)
id:4:initdefault:

After that line, you can start adding your custom auto-run process calls. Syntax is:
id:runlevel:action:process

So, if you want a program to be started, you can add one or more lines like followings:

#I do use this to automatically run both Apache and MySQL servers
s0:2345:wait:/home/server/apache/bin/apachectl start
s1:2345:wait:/home/server/mysql/bin/mysqld_safe –user=root &

Where s0 and s1 are custom defined IDs, 2345 are runlevels the rules applies to (all but shutdown and reboot), and wait means that the system should wait for the command to be executed before doing something else.

Pay attention do not change wait flag into respawn, or else you’ll have the system freezed at next reboot!

Apply changes made to inittab without rebooting

To see the effects of any changes you made to /etc/inittab without rebooting your machine, just type this command:
init q

Bookmark:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • digg
  • del.icio.us
  • blogmarks
  • co.mments
  • NewsVine
  • Furl

Related articles

Other posts filed under Linux

Comments and trackbacks

Add your comment:

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>