Take the 2-minute tour ×

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/my.sh

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

But my.sh 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

1 Answer 1

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


