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 can I run a script on the first book of my rhel 5 server after install.

I am using post kickstart tasks to create a script and I'd like to run it the first time the server boots. How can I do this?

I'd like to use the "firstboot" service

share|improve this question
up vote 3 down vote accepted

Is there any reason you NEED to use the firstboot service?

Take a look at: How to run script on first boot?

share|improve this answer

Create a script that tests for the existence or absence of a file. As the last step of a successful run of the script create/delete the status file. When preparing your image, you need to make sure the your status file is in the correct state.

share|improve this answer
Also, the file must be in a place that generally cannot be easily deleted by users. – mdpc Aug 10 '11 at 22:27
If the tasks you want to perform are really destructive you could simply have the script delete itself à la Mission Impossible, a 5 second warning is optional. – Zoredache Aug 10 '11 at 22:33

You need to echo your scripts to /etc/rc.d/rc.local, and maybe find a script that will replace those lines later using cron jobs but the way to do it is rc.d directory.

share|improve this answer

I came across the same problem; solved it by using the profile.d facility. In my case I had to be sure a file was present. If so then execute the file; after which I move the shell script from the profile.d directory to /tmp.

echo "Configure NVIDIA - xconfig."
cat << EOF > /etc/profile.d/
if [[ \$UID -ne 0 ]] ; then return 1 ; fi
if [ -f "/usr/bin/nvidia-xconfig" ]  
  mv -f /etc/X11/xorg.conf /etc/X11/xorg.conf.bk
  mv -f /etc/profile.d/ /tmp

Jos Plas

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.