CentOS: Set service to auto start

hi All,

I recently hired a VPS.  I have everything setup as i want it.  But went the server is rebooted it doesn;t automatically start the FTP and MySQL services.  So i have to manually type;


/etc/init.d/vsftpd start;
/etc/init.d/mysqld start;


How do i configure these services to automatically start?
LVL 2
detox1978Asked:
Who is Participating?
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.

jeremycrussellCommented:
Couple ways...

Look at "chkconfig" you can use this to manage service startup.. may require some modification of the init scripts..

Second way..

type "runlevel" to get what run level the server normally boots into, probably 3 or 5, you can also look at /etc/inittab.

Then, depending on the leve, go to the /etc/rc?.d directory.. so for runlevel 5 it would be /etc/rc5.d
in that directory, just link to the init script for the *S*tartup.

ln -s ../init.d/mysqld S99mysql
ln -s ../init.d/vsftpd S99vsftpd


If you would like, you can create corresponding links in runlevels to *stop* the services...  For example to kill the service when the machine is shutdown:

cd /etc/rc0.d/;ln -s ../init.d/K99mysqld

run "man init" to get more info on the runlevels at which level is "inited" when.
jeremycrussellCommented:
Correction:

cd /etc/rc0.d/;ln -s ../init.d/K99mysqld

should read
cd /etc/rc0.d/;ln -s ../init.d/mysqld K01mysqld
TRW-ConsultingCommented:
jeremycurssell's way of doing it manually with the 'ln' commands would work, but the way to do it if the init.d scripts were properly written is:

  chkconfig --add vsftpd
  chkconfig --add mysql

  chkconfig vsftpd on
  chkconfig mysql on

Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

detox1978Author Commented:
I had a look at the chkconfig and both services are listed as off. How do i edit the config so they are on?
Kerem ERSOYPresidentCommented:
As TRW-Consulting told. Though he had a typo the mysql daemon is called mysqld:

chkconfig mysqld on
chkconfig vsftpd on

Will enable the service

service mysqld start
service vsftpd start

Will start daemons..

cheers,
K.

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
detox1978Author Commented:
Many thanks,

I have another CentOS question about switching off cron notifications if you have time.

http://www.experts-exchange.com/OS/Linux/Q_26559002.html
tlrjohnCommented:
To stop the cron e-mail notifications just apped 2>&1 to end of the command.

Regards

P.S. You can use chkconfig --list to see what services are currently set to run.
      To start|stop a service for a run-level issue chkconfig --level <levels> <service_name> on|off
      To add a service to chkconfig issue chkconfig --add <service_name>

Hope that helps.
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
Linux Security

From novice to tech pro — start learning today.