Run something when Linux boots
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:
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:
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






