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

How to execute a script once at startup time on CentOS 6.3? I added file with following containment

#chkconfig: 2345 95 20
#description: Some description
sh /opt/somePath/

into /etc/ini.d and it works fine (I executed required chmod, chkconfig).

But file is compatible to run as service. And when I try to run in same way another .sh file (which can't to tun as service) I get exceptions on starting X.

So I want to know how I can run .sh files which are not services.


share|improve this question
up vote 3 down vote accepted

The simplest way to run a command once at startup is to put it in /etc/rc.d/rc.local, which is a link from /etc/rcX.d/S99local, and gets run at the very end of the boot sequence.

It's better to write, debug and link a proper service startup script, but if you're pushed for time and just want to whack in a one-line launch command, I find that's the best place to run it from.

share|improve this answer

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.