Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to be able to create a service so that the bash script will run every time the server boots up.

I am running CentOS 5.

I have been reading about chkconfig and creating a file in /etc/init.d for chkconfig to handle but I cannot seem to get it to work whenever I 'chkconfig servicename on' and then 'service servicename start'

When I do chkconfig --list my service is listed there.

Can someone provide me with a sample of the file I need to create in /etc/init.d and how to get everything running?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

If you just need a bash script to run one or more things every time the server starts, you can run the script from /etc/rc.local. Here's mine - it fires up my media server app by calling its startup script:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

#NK make sure nas is mounted:
mount -a
/etc/init.d/serviiod start
share|improve this answer

There is an initscript template on the Fedora Project website.

On the same page, below the template, are complete instructions for writing headers for initscripts on RedHat/Fedora/CentOS systems. You might need to do this if you need to ensure your script runs after other services are started, you only want the script to run in certain circumstances, or you want graphical system administration tools to display complete information about the script.

share|improve this answer

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.