Linux – How to make a startup script (linux) to load all of the programs (dameons) on startup

linuxscriptingunix

For example, I need to have the following script be executed on startup

service httpd start
service mysqld start
service sshd start
service pure-ftpd start
/usr/local/bin/noip2 start

I do NOT want to make an alias in the init.d folder for each and every program. Rather, can i make one text file to have all of these be called. That would be so much easier. Thank you!

Best Answer

You don't need a script to startup te services. Under RedHat-based distributions (which is what it appears you are using), running this:

chkconfig servicename on

Will automatically create the symlinks for startup for the appropriate run levels (In this case (3 to 5). Under debian-based distributions, you would do

update-rc.d servicename defaults

To do the same thing. In fact, you can also reorder you start priorities with this tool as well:

update-rc.d servicename defaults 91

With upstart (which is what current version of Ubuntu is using and what Red Hat is moving to), you can even add dependancies so that one process will start only after a specific service is up. More info here:

http://upstart.ubuntu.com/

At any event, if you don't want to use either of those mechanism, you can always use /etc/rc.local to start up your scripts. Unless there is a very good reason, just work with the tools that is already provided by your distro - it very likely better than what you can come up.