Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

Thanks.

share|improve this question
add comment

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
add comment

Your Answer

 
discard

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.