Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question

migrated from Jul 9 '11 at 14:06

This question came from our site for professional and enthusiast programmers.

You know there's a reason for those links in init.d. They allow the system to run the programs at startup but it ALSO shuts them down properly when the comp is being shut down. – Chris Jul 9 '11 at 4:25
-1 There's reasons things are done the way they are. You're asking for trouble. – Chris S Jul 9 '11 at 14:16
up vote 4 down vote accepted

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:

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.

share|improve this answer

Create a script with your commands and then add a cron job with @reboot like so:

crontab -e

@reboot /path/to/script

share|improve this answer
Oh cool. I never knew that one. Fancy. – arkigos Jul 9 '11 at 4:29

You can add those lines to /etc/rc.local. Note that it is run as 'root'.

share|improve this answer

You can just put a single script with each of those very commands in it in the init.d folder. I've done similar and it worked smashingly.

Flagged for move to Server Fault.

share|improve this answer

Make a bash script containing those commands and put it in the /etc/init.d/ directory.

Lets say you called it FOO. You then run

% update-rc.d FOO defaults

You also have to make the file you created, FOO, executable, using

$chmod +x FOO

share|improve this answer
He didn´t state he wanted to avoid the init.d directory entirely, just wanted to avoid creating a link for each one of the daemons – zad Jul 9 '11 at 4:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.