How to run a script at start up which loads a MySQL database?

My CentOS5 server boots to runlevel 3 so do I need to do anything other than:

1. Create script called /etc/rc.d/init.d/php_mysql_memory_table_maxmind that looks like this:
php -d /home/t1shopper/www/api/internal/maxmind/maxmind.php

Open in new window

2. Create symbolic link in /etc/rc.d/rc3.d called S99php_mysql_memory_table_maxmind linking to above file.

Now whenever the server reboots (or changes runlevel back to 3), it will run my script, right?

Note to self:
Geoff MillikanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You should not assume that php can be found at boot and use a complete path.

When the system will boot the script will run as you specify.

The script should include #chkconfig start stop
Presumably you do not want this script to run at other times.
Enclosing using the case to see whether a start, stop, or directive is being passed.
Geoff MillikanAuthor Commented:
How do I add the  #chkconfig start stop?
Look at any other script within /etc/init.d
The third item deals with run levels.

#chkconfig 99 10 3

case $1 in
         /usr/bin/php .....
         # nothing to be done
         *) #default
            echo "Usage: $0 (start|stop)"

Once you save in in /etc/init.d/
 You can use chkconfig to add this script
chkconfig --add scriptname
chkconfig --enable scriptname
chkconfig scriptname on.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Geoff MillikanAuthor Commented:
AWESOME!! Thanks so much, very helpful.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.